Vous êtes sur la page 1sur 9

SDM Institute of Technology,

Ujire-574240
Department of Information Science & Engineering
C-Contest (Probable questions)
Prepared by: Prof. Prasad B S, Asst Prof, Dept of ISE
Note: Suitable header files can be assumed to be included wherever necessary and missing header files cannot be reason for any answer.

1) main(){
char *p;
p="%d\n";
p++;
p++;
printf(p-2,300);}

a) compiler error b)300 c)Garbage value d)none of these


--------------------------------------------------------------------------------------------------------------
2)
main(){
unsigned int i;
for(i=1;i>-2;i--)
printf("c aptitude");}

a) c aptitude b) error c) prints nothing d) none of these


----------------------------------------------------------------------------------------------------------------
3)main(){
int a= 0;int b = 20;char x =1;char y =-1;
if(a,b,x,y)
printf("hello");
else
printf(world\n);}

a) hello b) world c) compiler error d) helloworld


----------------------------------------------------------------------------------------------------------------
4) main(){
int arr[3]={2,3,4};
char *p;
p=(char *)((int *)(p));
printf(%d,*p);
p=(int *)(p+1);
printf(%d,*p); }

a)2 3 4 b)2 0 c)2 d)Garbage values


----------------------------------------------------------------------------------------------------------------

5)
What is the output of this program ?
Union tag
{
int a;
char x,y;
}name;
(Assume storage is Little Endian technique)
int main() {
name.a=258;
printf(\n x=%d y=%d,name.x,name.y); }

a) x=1 y=1 b) x=2 y=2 c) x=1 y=2 d) error


----------------------------------------------------------------------------------------------------------------
6)
main() {
int i,k,l;
printf("%d",scanf("%d%d%d",&i,&k,&l));
}
what will be the output if, 0, 4, a are entered

a)0 b)2 c)3 d)none of these


----------------------------------------------------------------------------------------------------------------
7)
int i=8;
int j=2;
int k=(i&j) + (i&&j) + (i ^ j);
what is the value of k;

a)0 b)12 c)2 d)11


----------------------------------------------------------------------------------------------------------------
8)#include<stdio.h>
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); }

a)L b)M c)N d)O


----------------------------------------------------------------------------------------------------------------
9)#include<stdio.h>
main() {
struct xx {
int x=3;
char name[]="hello";
};
struct xx *s;
printf("%d\n",s->x);
printf("%s",s->name); }

a)3 and hello b) compiler error c)linker error d)none of these


----------------------------------------------------------------------------------------------------------------
10)main() {
printf("\nab");
printf("\bsi");
printf("\rha"); }
what is the output of above code:

a) hai b) ha c) asi d) aha


----------------------------------------------------------------------------------------------------------------
11) main()
{
int i=100000000097;
printf("%d %c\n",i,i); }

a)97,a b)unpredictable,a c)97,unpredictable d)compile time error


----------------------------------------------------------------------------------------------------------------
12)What is the output of the program ?
main(){
int i=1;
printf(i ? "one" : "zero"); }

a)one b)zero c)error d)both a and b


----------------------------------------------------------------------------------------------------------------
13)What is the output of the Program?
main(){
int a = 1;
#define p a;
printf("%d.. %d",a++,p++); }
a) 1..0 b)2..0 c)1..2 d)none of these
----------------------------------------------------------------------------------------------------------------
14) Array passed as an argument to a function is interpreted as

1) Address of the array


2) Values of the first elements of the array
3) Address of the first element of the array
4) Number of element of the array
----------------------------------------------------------------------------------------------------------------
15)
main(){
float a = 5.375;
char *p;
int i;
p=(char *)&a;
for(i=0;i<=3;i++)
printf("%02x",(unsigned char)p[i]); }

a)00 00 ac 40 b)00 ff ff 05 c)compiler error d)run time error saying illegal pointer conversion
----------------------------------------------------------------------------------------------------------------
16)# include<stdio.h>
aaa() {
printf("hi");
}
bbb(){
printf("hello");
}
ccc(){
printf("bye");
}
main()
{
int (*ptr[3])();
ptr[0]=aaa;
ptr[1]=bbb;
ptr[2]=ccc;
ptr[2]();
}
a)hihellobyebye b)hihellobye c)bye d)aaabbbcccbye
----------------------------------------------------------------------------------------------------------------
17)#include<stdio.h>
{
int s=0;
while(s++<10) {
if(s<4 && s<9)
continue;
printf("\n%d\t",s);
}}

1) 1 2 3 4 5 6 7 8 9 2) 1 2 3 10 3) 4 5 6 7 8 9 10 4) 4 5 6 7 8 9
----------------------------------------------------------------------------------------------------------------
18)struct point
{
int x;
int y;
};
struct point origin,*pp;
main()
{
pp=&origin;
printf("origin is(%d%d)\n",(*pp).x,pp->y);
}

a)origin is(garbage values) b)variables not initialized


c)origin is(0,0) d)none of these
----------------------------------------------------------------------------------------------------------------
19) main() {
int i=5,j=6,z;
printf("%d",i+++j);
}

a)11 b)12 c)Error: expression syntax d)unpredictable


----------------------------------------------------------------------------------------------------------------
20)What is the difference between ++*ip and *ip++ ?

a) both increment value


b) ++*ip increment value and *ip++ increment address
c) both increment address
d) ++*ip increment address and *ip++ increment value
----------------------------------------------------------------------------------------------------------------
21)What is the output of the following program ?
main()
{
int i;
i = f();
printf("%d",i );
}
int f()
{ return 1,3,2; }

a) 1 b) Compilation error c) 2 d) 3
----------------------------------------------------------------------------------------------------------------
22) #define square(x) x*x
main()
{
int i;
i = 64/square(4);
printf("%d",i);
}

a)4 b)64 c)16 d)256


----------------------------------------------------------------------------------------------------------------
23)#include<stdio.h>
#define FUN(i,j) i##j
void main() {
int val1=10;
int val12=20;
printf(%d,FUN(val1,2)); }

a) 10 b) 20 c) 1020 d) 12
----------------------------------------------------------------------------------------------------------------
24)main() {
int i=0;
if(i++)
main();
{
printf(f);
exit(0);}
main();
}

a)f b)f f f f f c)run time errord)compiler time error


----------------------------------------------------------------------------------------------------------------
25)main()
{
char *p;
int *q;
long *r;
p=q=r=0;
p++;
q++;
r++;
printf("%p...%p...%p",p,q,r);
}

a)000100010001 b)000100020004 c)111 d)compiler error


----------------------------------------------------------------------------------------------------------------
26)What is the output of the program.
main() {
printf("%d\n", f(7));
}
f(int x)
{
if (x <=4)
return x;
else
return (f(x--));
}

(a) 4 (b) 5 (c) 7 (d) infinite loop


----------------------------------------------------------------------------------------------------------------
27)#include <stdio.h>
void main() {
int I=3,*j,**k;
j=&I;
k=&j;
printf("%d%d%d",*j,**k,*(*k));
}
What is the output of the above program code?

1) 444 2) 000 3) 333 4) 433


----------------------------------------------------------------------------------------------------------------
28)main() {
int i;
i = abc();
printf("%d",i);
}
abc()
{
_AX = 1000;
}

a)1000 b) compiler error c)Garbage value d) none of these


----------------------------------------------------------------------------------------------------------------
29)void main() {
static int i=5;
printf(%d,i--);
if(i)
main(); }

a)5 infinite times b)5 4 3 2 1 c)run time error d)unpredictable


----------------------------------------------------------------------------------------------------------------
30)void main() {
char a[]="12345\0";
int i=strlen(a);
printf("here in 3 %d\n",++i); }

a)here in 3 5 b)here in 3 6 c)here in 3 7 d)none of these


----------------------------------------------------------------------------------------------------------------
31)void main() {
unsigned giveit=-1;
int gotit;
printf("%u ",++giveit);
printf("%u \n",gotit=--giveit); }

a)0 -1 b)compile error c)0 garbage d)0 65535


----------------------------------------------------------------------------------------------------------------
32)void main() {
int i;
char a[]="\0";
if(printf("%s",a))
printf("Ok here \n");
else
printf("Forget it\n"); }

a)Ok here b)Forget it c)Non portable pointer conversion d) runtime error


----------------------------------------------------------------------------------------------------------------

33)What is the output of the following code?


#include<stdio.h>
void swap(int&, int&);
void main() {
int a = 10,b=20;
swap (a++,b++);
printf("\n%d\t%d\t",a, b);
}
void swap(int& x, int& y)
{
x+=2;
y+=3; }

a) 14, 24 b) 11, 21 c) 10, 20 d) Error


----------------------------------------------------------------------------------------------------------------
34)void main() {
static int i=i++, j=j++, k=k++;
printf(i = %d j = %d k = %d, i, j, k);
}

a)expression syntax b)garbage values c)i=1 j=1 k=1 d)none of these


----------------------------------------------------------------------------------------------------------------
35)#define prod(a,b) a*b
main() {
int x=3,y=4;
printf("%d",prod(x+2,y-1)); }
a)15 b)12 c)10 d)none of these

----------------------------------------------------------------------------------------------------------------
36)main() {
unsigned int i=65000;
while(i++!=0);
printf("%d",i); }

a)65000 b)65535 c)0 d)1


----------------------------------------------------------------------------------------------------------------
37)What is the output of the program given below
main() {
signed char i=0;
for(;i>=0;i++) ;
printf("%d\n",i); }

a)-128 b)127 c)compiler error d)infinite loop


----------------------------------------------------------------------------------------------------------------
38) Pushdown list means:

a) Stack b) Queue c) Linked list d) All of the above


----------------------------------------------------------------------------------------------------------------
39) #if something = = 0
int some=0;
#endif
main() {
int thing = 0;
printf("%d %d\n", some ,thing); }

a)0 0 b)garbage 0 c)undefined variable d)syntax error


----------------------------------------------------------------------------------------------------------------
40)What is the output for the following program
main() {
int arr2D[3][3];
printf("%d\n", ((arr2D==* arr2D)&&(* arr2D == arr2D[0])) ); }

a)1 b)0 c)compile error d)run time error


----------------------------------------------------------------------------------------------------------------
*41)main ( ) {
static char *s[ ] = {black, white, yellow, violet};
char **ptr[ ] = {s+3, s+2, s+1, s}, ***p;
p = ptr;
**++p;
printf(%s,*--*++p + 3); }

a)black b)violet c)ck d)et


----------------------------------------------------------------------------------------------------------------
42)What is the output of the following code?
# include<stdio.h>
# define a 10
main() {
printf("%d..",a);
foo();
printf("%d",a); }
void foo() {
#undef a
#define a 50 }

1) 10..10 2) 10..50 3) Error 4) 0


----------------------------------------------------------------------------------------------------------------
43)main() {
int i=-1;
+i;
printf("i = %d, +i = %d \n",i,+i); }

a)i=-1, +i=1 b)i=-1, +i=0 c)i=-1, +i=-1 d)Error: Expression syntax


----------------------------------------------------------------------------------------------------------------
44)main() {
char *cptr , c;
void *vptr , v;
c=10; v=0;
cptr=&c; vptr=&v;
printf("%c%v",c,v);
}
a)10 0 b)size of v is unknown c)run time errord)none of these
----------------------------------------------------------------------------------------------------------------
45)main() {
char *str1="abcd";
char str2[]="abcd";
printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd")); }

a)5 5 5 b)4 4 4 c)2 4 4 d)none of these


----------------------------------------------------------------------------------------------------------------
46)main() {
char not;
not=!2;
printf("%d",not); }
a)253 b)0 c)compiler error d)none of these
47)What is the output of the following code?
#include<stdio.h>
void main() {
int a=0,b=0;
a = (b = 75) + 9;
printf("\n%d, %d",a, b); }

1) 75, 9 2) 75, 84 3) 84, 75 4) None of these options


----------------------------------------------------------------------------------------------------------------
48)main() {
int k=1;
printf("%d==1 is ""%s",k,k==1?"TRUE":"FALSE"); }

a)%d==1 is TRUE b)%d==1 is FALSE c)compiler error d)1==1 is TRUE

----------------------------------------------------------------------------------------------------------------
49)int i=10;
main() {
extern int i; {
int i=20; {
const volatile unsigned i=30;
printf("%d",i); }
printf("%d",i); }
printf("%d",i); }

a)30 30 30 b)30 20 20 c)30 20 10 d)10 10 10


----------------------------------------------------------------------------------------------------------------
50)#include<stdio.h>
main() {
const int i=4;
float j;
j = ++i;
printf("%d %f", i,++j); }

a)5 6 b)5 5 c)4 5 d)compiler error

----------------------------------------------------------------------------------------------------------------

***********ALL THE BEST********

Vous aimerez peut-être aussi