Você está na página 1de 4

ROLL NO.

___________________

Subject: PROG. & PROBLEM SOLVING THROUGH C

Code: AC05/AT05

AMIETE CS/IT (OLD SCHEME)

OCTOBER 2012

Time: 3 Hours

Max. Marks: 100

PLEASE WRITE YOUR ROLL NO. AT THE SPACE PROVIDED ON EACH


PAGE IMMEDIATELY AFTER RECEIVING THE QUESTION PAPER.
NOTE: There are 9 Questions in all.
Question 1 is compulsory and carries 20 marks. Answer to Q.1 must be written
in the space provided for it in the answer book supplied and nowhere else.
The answer sheet for the Q.1 will be collected by the invigilator after 45
Minutes of the commencement of the examination.
Out of the remaining EIGHT Questions answer any FIVE Questions. Each
question carries 16 marks.
Any required data not explicitly given, may be suitably assumed and stated.
Q.1
Choose the correct or the best alternative in the following:
(2 10)
a. The global variables by default belong to
(A) the register type
(C) the auto type

(B) the static type


(D) the extern type

b. What will be the output of the following program?


# include <stdio.h>
int main() {
int i=5 ,j;
j=++i+++i+++i;
printf("%d

%d" ,i ,j);

return 0;
}
(A) 7 21
(C) 7 24

(B) 8
(D) 8

21
24

c. What will be the output of the following C code?


# include <stdio.h>
int main() {
int check =2
switch ( check) {
case 1: printf (" Car");
case 2 : printf (" Aeroplane");
case 3 : printf (" Train");
default : printf (" Auto");
}
return 0;
}
(A) Aeroplane
(C) Aeroplane Train Auto
AC05/AT05 / OCTOBER 2012

(B) Auto
(D) Aeroplane Train
1

AMIETE CS/IT (OLD SCHEME)

ROLL NO. ___________________

Code: AC05/AT05

Subject: PROG. & PROBLEM SOLVING THROUGH C

d. What will be the output of the following program?


# include <stdio.h>
int main() {
int i=1;
i=2+2*i++;
printf("%d ",i);
return 0;
}
(A) 4
(C) 6
e.

(B) 5
(D) 7

What will be output of following C code?


#include <stdio.h>
int main(){
int x = 011;
for (int i =0; i<x; i+=3) {
printf(Start);
continue;
printf(End);
}
return 0;
}
(A) Start End Start End Start End (B) Start Start Start
(C) Start End Start
(D) Start Start Start Start

f. Following are complexity of sorting algorithms. Which algorithm will you


prefer?
(B) O(n2)
(D) O(log n)

(A) O(n)
(C) O(n log n)

g. Which of the following is not a keyword in C?


(A) goto
(C) continue

(B) constant
(D) All of these are C keywords

h. What is the value of the expression a - b / 3 + c * 2 - 1, given a = 9, b = 12


and c = 3?
(A) 10
(C) - 4

(B) 3
(D) 2

i. Which of the following is not a preprocessor statement in C?


(A) # ifdef
(C) #elseif
AC05/AT05 / OCTOBER 2012

(B) # ifndef
(D) # endif
2

AMIETE CS/IT (OLD SCHEME)

ROLL NO. ___________________

Code: AC05/AT05

Subject: PROG. & PROBLEM SOLVING THROUGH C

j. What is the value assigned to address by the following statements, when input
is NEW YORK?
char address [10];
scanf(%s, address);
(A) NEW YORK
(C) NEW

(B) NEWYORK
(D) YORK

Answer any FIVE Questions out of EIGHT Questions.


Each question carries 16 marks.
Q.2

a. Describe the function of the following software:


(i) assembler
(ii) compiler
(iii) interpreter
(iv) linker
(v) loader

(10)

b. Explain topdown approach of program design with an example. What are


its advantages?
(6)
Q.3

a. How is upper bound time complexity of an algorithm measured? Give an


example.
(4)
b. Write an algorithm to find whether a given year is a leap year or not.

(6)

c. What is a recursive function? What are its basic properties? Write a


function which finds the sum of first n integers; where n is the argument to
the function.
(6)
Q.4

a. Write any four format codes that are used in scanf statement. Write a scanf
statement to read age(int) , sex(char), grade (float), and name (string).
(4)
b. Give the syntax of for statement and describe the control flow in that
statement. Write a for statement to print the multiplication table of 2, 3 and
4.
(6)
c. Write a program to find the largest element and its position in an array.

Q.5

(6)

a. Explain call by value and call by reference approach of passing arguments


to a function. Write a simple function to swap two values and illustrate call
by value and call by approach.
(6)
b. Differentiate structure and union by giving suitable examples.

(4)

c. Explain with example, the syntax and usage of the following in C program.
(i) Nested Structure Definition
(ii) Array of structures
(6)

AC05/AT05 / OCTOBER 2012

AMIETE CS/IT (OLD SCHEME)

ROLL NO. ___________________

Code: AC05/AT05
Q.6

Subject: PROG. & PROBLEM SOLVING THROUGH C

a. Give the meaning of the following declarations:


(i) char *c;
(ii) int *fptr();
(iii) float *aptr[20];
(iv) int (*ptrf)(int);
(v) float (*ptra)[10];
(vi) int y = *p1 + *p2;
(vii) int larger(int *, int *);
(viii) char *p = (char *) &x;

(4)

b. Write a function to copy a string to another, without using library function. (6)
c. Explain with an example program the following operations on a file-open,
read and close.
(6)
Q.7

a. Write a C program that accept name and marks scored by students in five
subjects. Use functions
(i) ADD to add records with student names and marks to a file
(ii) CALCULATE to read the records from the file, calculate the result and
display.
(10)
b. Write a C function to insert an element into a sorted linked list. Assume
each node has an integer value and a pointer to the next element.
(6)

Q.8

a. Define macros for finding:


(i) Sum

(ii) Max of two values.

(6)

b. What are the guidelines for construction of statements and guidelines for
input/ output formats during coding?
(6)
c. Write an algorithm to reverse the digits of an integer.
Q.9

(4)

a. What is dynamic memory allocation? How does it help in building


complex programs? What is the task of following memory allocation
functions?
(i) malloc
(ii) calloc
(iii) free
(iv) realloc
(8)
b. Differentiate the use of break and continue statements with an example.

(4)

c. Indicate how the output is displayed with the following statements?


printf(%6d,12345);
printf(%4d,12345);
printf(%-6,12345);
printf(%06d,12345);

(4)

AC05/AT05 / OCTOBER 2012

AMIETE CS/IT (OLD SCHEME)

Você também pode gostar