Professional Documents
Culture Documents
#include<stdio.h>
struct marks{
int p:3;
int c:3;
int m:2;
};
int main(){
struct marks s={2,-6,5};
printf("%d %d %d",s.p,s.c,s.m);
return 0;
(a) 2 -6 5
(b) 2 -6 1
(c) 2 2 1
(d) Compiler error
(e) None of these
Answer: (c)
Explanation:
#include<stdio.h>
int main(){
int huge*p=(int huge*)0XC0563331;
int huge*q=(int huge*)0xC2551341;
*p=200;
printf("%d",*q);
return 0;
(a)0
(b)Garbage value
(c)null
(d) 200
(e)Compiler error
Answer: (d)
Explanation:
Answer:
#include<dos.h>
#include<stdio.h>
int main(){
union REGS i,o;
int x,y,k;
//show mouse pointer
i.x.ax=1;
int86(0x33,&i,&o);
while(!kbhit()) //its value will false when we hit
key in the key board
{
Copyright@ritesh kumar: http://cquestionbank.blogspot.com/
Page 4
i.x.ax=3; //get mouse position
x=o.x.cx;
y=o.x.dx;
printf("(%d , %d)",x,y);
delay(250);
int86(0x33,&i,&o);
}
return 0;
}
Answer:
#include <stdio.h>
#include <dos.h>
#include<stdio.h>
int main(){
int i;
float a=5.2;
char *ptr;
ptr=(char *)&a;
for(i=0;i<=3;i++)
printf("%d ",*ptr++);
return 0;
}
Copyright@ritesh kumar: http://cquestionbank.blogspot.com/
Page 7
(a)0 0 0 0
(b)Garbage Garbage Garbage Garbage
(c)102 56 -80 32
(d)102 102 -90 64
(e)Compiler error
Answer: (d)
Explanation:
#include<stdio.h>
int main(){
int i;
double a=5.2;
char *ptr;
ptr=(char *)&a;
for(i=0;i<=7;i++)
printf("%d ",*ptr++);
return 0;
Answer: (a)
Explanation:
Copyright@ritesh kumar: http://cquestionbank.blogspot.com/
Page 9
In c double data type is eight byte data type while
char pointer ptr can point one byte of memory at a
time.
#include<stdio.h>
int main(){
Copyright@ritesh kumar: http://cquestionbank.blogspot.com/
Page 11
printf("%s","c" "question" "bank");
return 0;
}
Answer: (d)
Explanation:
#include<stdio.h>
int main(){
char *str="c-pointer";
printf("%*.*s",10,7,str);
return 0;
}
(a) c-pointer
(b) c-pointer
(c) c-point
(d) cpointer null null
(e) c-point
Answer: (e)
Explanation:
#include<stdio.h>
int main(){
int a=-12;
a=a>>3;
printf("%d",a);
return 0;
}
(a) -4
(b) -3
(c) -2
(d) -96
(e) Compiler error
Answer :( c)
Explanation:
#include<stdio.h>
#include <string.h>
int main(){
printf("%d %d",sizeof("string"),strlen("string"));
return 0;
}
(a) 6 6
(b) 7 7
(c) 6 7
(d) 7 6
(e) None of these
Answer: (d)
Explanation:
#include<stdio.h>
int main(){
static main;
int x;
x=call(main);
printf("%d ",x);
return 0;
}
(a) 0
(b) 1
(c) Garbage value
(d) Compiler error
(e) None of these
Answer: (b)
Explanation:
#include<stdio.h>
int main(){
int a,b;
a=1,3,15;
b=(2,4,6);
printf("%d ",a+b);
return 0;
}
(a) 3
(b) 21
(c) 17
(d) 7
(e) Compiler error
Answer: (d)
Explanation:
#include<stdio.h>
int extern x;
int main()
printf("%d",x);
x=2;
return 0;
}
int x=23;
(a) 0
(b) 2
(c) 23
(d) Compiler error
(e) None of these
Answer: (c)
Explanation:
#include<stdio.h>
int main(){
int i=0;
if(i==0){
i=((5,(i=3)),i=1);
printf("%d",i);
}
else
printf("equal");
}
(a) 5
(b) 3
(c) 1
(d) equal
(e) None of above
Answer: (c)
int main(){
int a=25;
printf("%o %x",a,a);
return 0;
}
(a) 25 25
(b) 025 0x25
Copyright@ritesh kumar: http://cquestionbank.blogspot.com/
Page 19
(c) 12 42
(d) 31 19
(e) None of these
Answer: (d)
Explanation:
#include<stdio.h>
#include<stdio.h>
#define call(x) #x
int main(){
printf("%s",call(c/c++));
return 0;
}
(a)c
(b)c++
(c)#c/c++
(d)c/c++
(e)Compiler error
Answer: (d)
Explanation:
test.c 1:
test.c 2: void main(){
test.c 3: printf("%s","c/c++");
test.c 4: return 0;
test.c 4: }
test.c 5:
#include<stdio.h>
int main(){
if(printf("cquestionbank"))
printf("I know c");
else
printf("I know c++");
return 0;
}
(a) I know c
(b) I know c++
(c) cquestionbankI know c
(d) cquestionbankI know c++
(e) Compiler error
Answer: (c)
Explanation:
#include<stdio.h>
(a) Equal
(b) Greater than
(c) Less than
(d) Compiler error
(e) None of above
Answer: (d)
Explanation:
#include<stdio.h>
int main(){
Copyright@ritesh kumar: http://cquestionbank.blogspot.com/
Page 23
printf("%s",__DATE__);
return 0;
Answer: (a)
Explanation:
#include<stdio.h>
void start();
void end();
#pragma startup start
#pragma exit end
int static i;
int main(){
printf("\nmain function: %d",++i);
return 0;
void end(){
printf("\nend function: %d",++i);
}
(a)
main function: 2
start function: 1
end function:3
(b)
start function: 1
main function: 2
end function:3
(c)
main function: 2
end function:3
start function: 1
(d) Compiler error
(e) None of these
Answer: (b)
Explanation: