Anda di halaman 1dari 11

SAMPLE QUESTION PAPER PF

1. What would be the output of the following program ?


#include <stdio.h>
main()
{
printf(%f,sqrt(36.0));
return 0;
}
a) 36 b) Garbage b) 6.0 c) none
Ans : b
2. What is the output of the following code segment :
Void main()
{
int a=10,c;
c=a++ + ++a + ++a +a;
printf(%d%d,c,a);
}
a) 48, 12 b) 48, 13 c) 44 , 14 d) 44, 12
Ans : b

3. What output will the following code fragment produce if the input is 2000 ?
int val,res,n=1000;
scanf(%d,&val);
res=n + val > 1750 ? 400 : 200;
printf(%d,res);
a) 600 b) 400 b) 200 c) none
Ans : b

4. What would be the output of the following code ?


#define MESS junk
main()
{
printf(MESS);
}
a) junk b) Mess c) MESS junk d) MESS
Ans : d
5. consider the following array declarations.
int X[5][50];
long Y[5][10];

char Z[18];
short A[20];
Find the total no.of bytes required to store each array.
a) X:500 bytes ,Y: 200 bytes , Z:18 bytes , A:40 bytes
b) X:200 bytes ,Y: 200 bytes , Z:18 bytes , A:40 bytes
c) X:500 bytes ,Y: 20 bytes , Z:18 bytes , A:10 bytes
Ans : a
6. find out the output :
main()
{
int i=5; j=6; z;
printf(%d,i+ ++j);
}
a) 13 b) 11 c) 12 c) 10 d) none
Ans : b
7. To access the members of a structure we use __________
a) -> b) this c) super d) .
Ans : d
8. what is the output of the following :
int ia = 5, ix,iy
ix=ia++;
printf(%d, ix);
iy=ia; ix=++ia;
printf(%d, ix);
a) 5, 6 b) 6,5 c) 6,7 d) none
Ans : c
9. What is the output of following fragment :
void main()
{
int ichoice;
scanf(%d,&ichoice);
switch(ichoice)
{
case 1 :
case 2:
case 3: printf(dennis Ritchie);
break;
default : printf(DENNIS RITCHIE);
break;
}
}
a) DENNIS RITCHIE b) dennis Ritchie c) both d) none

Ans : b
10. What is output for the following code :
# include <stdio.h>
# define MAX 10
void main()
{
# if MAX > 99
printf( MAX is greater than 99);
#elseif MAX < 0
printf(MAX is less than 0);
# else
printf(MAX is 10);
}
a ) MAX is less than 0 b) MAX is greater than 99 c) MAX is 10
Ans : c
11. What is the use of %[ ]?
a) scanning a set of unwanted symbols b) scanning a set of characters
c) scanning a set of unbounded array d) scanning a set of only integers.
Ans : b
12. How many digits of precision can float and double store up ?
a) 4 & 8 b) 6 & 12 c) 5 & 10 d) 3 & 6
Ans : b
13. What would be the output of the following code :
main()
{
int i=3;
switch (i)
{
default : printf(zero);
case 1 : printf(one);
break;
case 2: printf(two);
break;
case 3: printf (three);
break;
}
}
a) zero b) one c) two d) error e) three
Ans : e
14. Preprocessor section is used in C program for the following three purposes.
Choose the option which is not used.

a) to link system lib files b) for defining the cond. Inclusion


c) for defining variables
d) for defining the macros
Ans : c
15. Give the correct order for the complete execution of the C program
i) create program ii) execute program iii) compile program
iv) linking program
a) i,iii,iv,ii b) i,iii,ii,iv c) i,iv,iii,ii d) i,iv,ii,iii
Ans : a
16. What is output for the following segment :
for (icount=1; icount<=10; icount++)
{
if (icount % 2==0)
{
continue;
}
printf(%d,icount);
}
a) 13579 b) 2468 c) 123456789 d) none
Ans : a
17. Pass by value takes
a) less time for execution, because the values are copied
b) more time for execution, because the values are copied
b) less time because no values are copied
c) none
Ans : b
18. A binary Search can be applied only to a
a) sorted list of items b) unsorted list of items c) none
Ans : a
19. what is the output for following segment :
for (icount=0;icount < 10; icount++) {
if (icount==5) {
continue;
}
printf(%d,icount);
}
a) code display 1 to 9 except 5 b) display 1 to 10
c) display 5 only
Ans : a
20. if the iterations in the outermost loop is 3 and the iterations in the
innermost is 4, then how many times the statements in the inner most

loop gets executed ?


a) 10 b) 11 c) 13 d) 12
Ans : d
21.What are the types of control structures available in C ?
a) Sequential , Selectional , conditional
b) Sequential , Selectional , Iterational
c) Sequential , Repetitional, ,iterational
Ans : b
22.Which following Escape Sequence causes an audible sound on the
computer ?
a ) \t b) \t c) \b d) \n
Ans : a
23. Address of the operator (&) is used to
a) print the address of variable b) fetch the memory address of a variable
c) It is output function d) none
Ans : b
24.The purpose of the following program
b = s + b; s = b - s; b = b - s;
where s, b are two integers is to
a) transfer contents of s to b
b) transfer contents of b to s
c) exchange (swap) the contents of s and b
d) negate the contents of s and b
Ans : c
25.Consider the function
find(int x, int y)
{
return ((x < y) ? 0: (x - y));
}
The call find(a, find(a,b)) can be used to find
a) maximum of a , b b) positive difference of a, b
c) sum of a, b d) minimum of a, b
Ans : d

26. Which of the following options correctly relates / and %


a) b = (a/b) * b + a%b
b) a = (a/b) * b + a%b
c) b = (a%b) * b + a/b
d) a = (a%b) * b + a/b
Ans : b

27. Consider the following program fragment.


char c = 'a';
while(c++ <= 'z')
putchar(xxx);
If the required output is abcd ... xyz, then xxx should be
a) c
b) c++
c) c-1
d) --c
Ans : c
28. The value of an automatic variable that is declared but not initialised will be
a) 0
b) -1 c) unpredictable d) none of the above
Ans : c
29. When a variable of data type double is converted into float
a) rounding takes place
b) truncation takes place
c) the lower order bits are dropped
d) none of the above
Ans : a
30. Which of the following comments regarding the reading of string, using
scanf( with %s option ) and gets is true
a) Both can be used interchangibly
b) scanf is delimited by end of line, while gets is not
c) scanf is delimited by blank space, while gets is not
d) none of the above
Ans : c
31. The following program
if (a = 0)
printf("a is zero");
else
printf("a is nonzero");
results in printing of
a) a is zero b) a is not zero c) nothing d) garbage
Ans : b
32. The following loop , what is the output :
for(i =1, j = 10; i <6; ++i,--j)
printf("%d %d",i ,j);

a) 1 10 2 9 3 8 4 7 5 6
b 1 2 3 4 5 10 9 8 7 6
c) 1 1 1 1 1 9 9 9 9 9
d) none of the above
Ans : a
33.What is output of the following segment :
main()
{ int i = 5;
if( i == 5) return;
else printf("i is not five");
printf("over");
a) a syntax error
b) an execution error
c) over
d) execution termination, without printing anything
Ans : d
34. What is output for the following program fragment
int i = 5;
do
{
putchar(i+100);
printf("%d",i--);
}
while(i);
a)i5h4g3f2e1
b) i4h3g2f1e0
c) an error message
d) none of the above
Ans : a
35. In a for loop if the condition is missing then
a) it is assumed to be present and taken to be false
b) it is assumed to be present and taken to be true
c) it results in syntax error
d) execution will be terminated abruptly
Ans : b
36. Consider the following program fragment
if( a > b)
if( b > c)
s1;

else s2;
s2 will be executed if
a) a <= b
b) b > c
c) b <=c and a <=b
d) a > b and b <= c
Ans : d
37. If storage class is missing in the array definition, by default it will be taken to be
a) automatic
b) external
c) static
d) either automatic or external depending on the place of occurrence
Ans : d
38. While passing an array as an actual argument, the function call must have
a) the array name with empty brackets
b) the array name with its size
c) the array name alone
d) none of the above
Ans : c
39. The default parameter passing mechanism is
a) call by value
b) call by reference
c) call by value result
d) none of the above
Ans : a
40. Use of macro instead of function is recommended
a)When one wants to reduce the execution time
b)When there is a loop within a function call inside
c) when a function is called in many places in a program
d) in all the above cases
Ans : a
41. Which of the following is syntactically correct ?
a) for();
b) for(;);
c) for(,);
d) for(;;);
Ans : d

42. A function q that accepts a pointer to a character as argument and returns a pointer to
an array of integer can be declared as
a) int (*q(char *))[]
b) int *q(char *)[]
c) int (*q)(char *)[]
d)none of the above
Ans : a
43. What mode is used for Read write operations used in File ?
a) a+ b) w+ c) w d) r e) none
Ans : a
44. What is the output for the following segment :
#include <stdio.h>
#include <string.h>
int main(void)
{
char *p;
p=memchr(this is a test, ,14);
printf(p);
return 0;
}
a) this b) this is a test c) is a test d) test
Ans : c
45. Point out the error , if any , in the for loop :
main()
{
int i=1;
for(;;)
{
printf(%d,i++);
if (i>10)
break;
}
}
a. the condition in the for loop is a must.
b. the two semi colons should be dropped
c. the for loop should be replaced by a while loop
d. No error
Ans : d
46. What is the use of %[ ]?
a) scanning a set of characters b) scanning a set of unwanted symbols
c) scanning a set of unbounded array d) scanning a set of only integers.
Ans : a

47. Predict the output :


Int main()
{
float x=5.999;
float *y,*z;
y=&x; z=y;
Printf(%f, %f, %f, %f ,x, *(&x),*y,*z);
Return o;
}
a) 5.999,5.999,5.999,5.999
b) 5.99,5.999,5.999,5.999
c) 5.999,5.999,5.99,5.999
c) 5.999, X999.9, 5999.
Ans : a

48. Given the following segment :


int ival=1024;
char ch=70;
int i=a;
const int ic=i;
Which of the following are illegal ?
a) i=ic; b) ic=i; c) ch=i; d) i=ch; e) none
Ans : b
49. What is the initial value of i,j,R;
static int i=i++, j=j++, R=R++;
printf(%d ,%d,%d, I,j,R);
a) Error b) 0 0 0 c) 1 1 1 d) none
Ans : b
50. What is output for the following segment :
unsigned int icount=1;
while (icount<10);
{
printf(%u , icount);
}
a) finite loop b) display 1 to 10 c) infinite loop d) display 10
Ans : c
*******

Anda mungkin juga menyukai