Professional Documents
Culture Documents
Sample Paper
Sample Paper
Code:
short testarray[4][3]={{1},{2,3},{4,5,6}};
printf(“%d\n”, sizeof(testarray) );
Assuming a short is two bytes long, what will be printed by the above code?
a) it will not compile because not enough initializers are given.
b) 6 c)7 d) 12 e)24
Q2.
main()
{
int i=-5,j=-2;
junk(i,&j);
printf(“\n i=%d j=%d”,i,j);
Q3.
Char ** array[12][12][12]
Consider array, defined above. Which one of the following definitions and
initializations of p is valid?
Q4.
#include<stdio.h>
main()
{
int a,b=5;
a=b+NULL;
printf(“%d”,a);
}
Q6.
#include<stdio.h>
void main()
{
printf("%d%d",sizeof(NULL),sizeof(""));
}
a) 0 1 b)4 2 c) 2 1 d)1 1
Q8. Which one of the following will read a character from the keyboard and will
store it in the variable c?
a) c=getc(); b)getc(&c); c) c=getchar(stdin); d) getchar(&c)
e) c=getchar();
Q9.
#include<stdio.h>
void main()
{
int x=3;
x*=x+4;
printf("%d",x);
}
a) 13 b) 17 c) 21 d) 25
Q10.
#include<stdio.h>
void main()
{
int a[]={10,20,30,40,50};
int j;
for(j=0;j<5;j++)
{
printf("\n%d",*a);
a++;
}
}
a) 10 20 30 40 50 b) Lvalue Required
c) 50 40 30 20 10 d) Garbage Value
Q13.
#include<stdio.h>
void main()
{
int n[25];
n[0]=100;
n[24]=200;
printf("\n%d%d",*n,*(n+24)+*(n+0));
}
Q14
Code:
#include <stdio.h>
int i;
void increment(int i)
{
i++;
}
int main()
{
for(i=0;i<10;increment(i) )
{
}
printf(”i=%d\n”,i);
return 0;
}
What will happen when the program above is compiled and executed?
a)it will not compile b) it will print out: i=9 c) it will print out:
i=10
d) it will print out: i=11 e) it will loop indefinitely.
15.
#include<stdio.h>
void main()
{
// assime that the array begins at address 1200
int arr[]={2,3,4,1,6};
printf("%u%d",arr,sizeof(arr));
}
16.
#include<stdio.h>
void main()
{
int a[3][4]={1,2,3,4,4,3,2,8,7,8,9,0};
int *ptr=&a[0][0];
fun(&ptr);
}
fun(int **p)
{
printf("\n%d",**p);
}
a) 4 b)3 c) 2 d) 1
17.
#include<stdio.h>
void main()
{
int arr[]={0,1,2,3,4};
int i,*p;
for(p=arr,i=0;p+i<=arr+4;p++,i++)
printf("%d",*(p+i));
}
a) 0 1 2 b) 2 3 4 c) 0 2 4 d) 0 1 2 3 4
18.
#include<stdio.h>
void main()
{
int arr[]={0,1,2,3,4};
int *ptr;
for(ptr=arr+4;ptr>=arr;ptr--)
printf("%d",arr[ptr-arr]);
}
a) 4 5 6 7 8 b) 4 3 2 1 0 c) 8 7 6 5 4 d) 4 3 2 1 0
19.
Code:
int i=4;
switch(i)
{
Default:
;
case 3:
i+=5;
if(i= =8)
{
i++;
if(i= =9) break;
i*=2;
}
i - =4;
break;
case 8 :
i+=5;
break;
}
printf(“i=%d\n”,i);
a) #include<sysheader.h> b) #incl”sysheader.h”
c)#includefile<sysheader>
d) #include sysheader.h e) #incl <sysheader.h>
23
Code:
int x=0;
For (x=1;x<4;x++)
Printf(“x=%d\n”, x);
What will be printed when the sample code above is executed?
24
Code:
int x=3;
if(x==2);
x=0;
if(x==3)
x++;
else x+=2;
a) 1 b) 2 c) 3 d) 4 e) 5
25
Code:
Char *ptr;
Char myString[] = “abcdefg”;
Ptr=myString;
Ptr+=5;
26
double x= -3.5 , y=3.5;
Code:
printf(“ 0f : % 0f \n” , ceil (x) , ceil (y) ) ;
printf(“ 0f : % 0f \n” , floor (x) , floor (y) ) ;
a) -3:4
-4=3
b) -4:4
-3:3
c) -4:3
-3:4
d) -4:3
-3:4
e) -3:3
-4:4
a) int *x;
*x=0x200;
d) int *x = 0x200;
e) int *x(&0x200);
28
Code
int x =5;
int y= 2;
char op= ‘*’ ;
switch (op)
{
default : x+= 1;
case ‘+’ : x +=y /* It will go to all th case */
case ‘-‘ : x-= y;
After the sample code above has been executed, what value will variable x
contain?
a) 4 b) 5 c) 6 d) 7 e) 8
29. Code
x=3, counter=0;
while((x-1))
{
++counter;
x--;
}
a) 0 b) 1 c) 2 d) 3 e) 4