C Question Paper1
C Question Paper1
TOTAL MARKS: 25
2. main()
{
static int var = 5;
printf("%d ",var--);
if(var)
main();
}
a> 12345
b> 54321
c> Compiler Error
d> None of the above
3. main()
{
int c[ ]={2.8,3.4,4,6.7,5};
int j,*p=c,*q=c;
for(j=0;j<5;j++) {
printf(" %d ",*c);
++q; }
Page 1 of 6
for(j=0;j<5;j++){
printf(" %d ",*p);
++p; }
}
a> 2233446557
b> 2222223465
c> 28344675
d> None of the above
4. main()
{
int c=- -2;
printf("c=%d",c);
a> -2
b> 2
c> Syntax Error
d> None of the above
5. main()
{
char *p;
printf("%d %d ",sizeof(*p),sizeof(p));
}
a> 2 2
b> 1 2
c> 2 1
d> None of the above
6. main()
{
Page 2 of 6
int i=10;
i=!i>14;
Printf ("i=%d",i);
}
a> i = 0
b> i = 14
c> Syntax Error
d> None of the above
7. #include
main()
{
struct xx
{
int x=3;
char name[]="hello";
};
struct xx *s;
printf("%d",s->x);
printf("%s",s->name);
}
a> Compiler Error
b> Syntax Error
c> 3 hello
d> None of the above
8. main()
{
int i=5;
printf("%d%d%d%d%d%d",i++,i--,++i,--i,i);
}
a> 55455
b> 45545
Page 3 of 6
c> 45455
d> None of the above
9. #include
main()
{
int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} };
int *p,*q;
p=&a[2][2][2];
*q=***a;
printf("%d----%d",*p,*q);
}
10.
main()
{
char *p;
p="Hello";
printf("%c\n",*&*p);
}
a> Hello
b> H
c> Some garbage value
d> None of the above
Marks: 15
1. main()
{
extern int i;
Page 4 of 6
i=20;
printf("%d",i);
}
2. #include
main()
{
char s[]={'a','b','c','\n','c','\0'};
char *p,*str,*str1;
p=&s[3];
str=p;
str1=s;
printf("%d",++*p + ++*str1-32);
}
3. #include
main()
{
struct xx
{
int x;
struct yy
{
char s;
struct xx *p;
};
struct yy *q;
};
}
4. main()
{
int i=1;
while (i<=5)
{
printf("%d",i);
Page 5 of 6
if (i>2)
goto here;
i++;
}
}
fun()
{
here:
printf("PP");
}
5. #include
main()
{
struct xx
{
int x=3;
char name[]="hello";
};
struct xx *s=malloc(sizeof(struct xx));
printf("%d",s->x);
printf("%s",s->name);
}
Page 6 of 6