Sunteți pe pagina 1din 21

1.

What will be output when you will execute


following c code?
#include<stdio.h>
int main(){
printf("%d\t",sizeof(6.5));
printf("%d\t",sizeof(90000));
printf("%d",sizeof('A'));
return 0;
}
Choose all that apply:
(A) 4 2 1
(B) 8 2 1
(C) 4 4 1
(D) 8 4 1
(E) 8 4 2
2. Consider on following declaring of enum.
(i) enum cricket
{Gambhir,Smith,Sehwag}c;
(ii) enum cricket {Gambhir,Smith,Sehwag};
(iii) enum {Gambhir,Smith=-5,Sehwag}c;
(iv) enum c {Gambhir,Smith,Sehwag};
Choose correct one:
(A) Only (i) is correct declaration
(B) Only (i) and (ii) is correct declaration
(C) Only (i) and (iii) are correct declaration
(D) Only (i),(ii) and are correct declaration
(E) All four are correct declaration
3. What will be output when you will execute
following c code?
#include<stdio.h>
int main(){
signed x;
unsigned y;
x = 10 +- 10u + 10u +- 10;
y = x;
if(x==y)
printf("%d %d",x,y);
else if(x!=y)
printf("%u %u",x,y);
return 0;
}
Choose all that apply:
(A) 0 0
(B) 65536 -10
(C) 0 65536
(D) 65536 0
(E) Compilation error
4. Which of the following is not modifier of
data type in c?
(A) extern
(B) interrupt
(C) huge
(D) register
(E) All of these are modifiers of data type
5. What will be output when you will execute
following c code?
#include<stdio.h>
int main(){
double num=5.2;
int var=5;
printf("%d\t",sizeof(!num));
printf("%d\t",sizeof(var=15/2));
printf("%d",var);
return 0;
}
Choose all that apply:
(A) 4 2 7
(B) 4 4 5
(C) 2 2 5
(D) 2 4 7
(E) 8 2 7
6. What will be output when you will execute
following c code?
#include<stdio.h>
int main(){
const int *p;
int a=10;
p=&a;
printf("%d",*p);
return 0;
}
Choose all that apply:
(A) 0
(B) 10
(C) Garbage value
(D) Any memory address
(E) Error: Cannot modify const object
7. Consider on following declaration:
(i) short i=10;
(ii) static i=10;
(iii) unsigned i=10;
(iv) const i=10;
Choose correct one:
(A) Only (iv) is incorrect
(B) Only (ii) and (iv) are incorrect
(C) Only (ii),(iii) and (iv) are correct
(D) Only (iii) is correct
(E) All are correct declaration
8. What will be output when you will execute
following c code?
#include<stdio.h>
int main(){
signed x,a;
unsigned y,b;
a=(signed)10u;
b=(unsigned)-10;
y = (signed)10u + (unsigned)-10;
x = y;
printf("%d %u\t",a,b);
if(x==y)
printf("%d %d",x,y);
else if(x!=y)
printf("%u %u",x,y);
return 0;
}
9. What will be output when you will execute
following c code?
#include<stdio.h>
const enum Alpha{
X,
Y=5,
Z
}p=10;
int main(){
enum Alpha a,b;
a= X;
b= Z;
printf("%d",a+b-p);
return 0;
}
Choose all that apply:
(A) -4
(B) -5
(C) 10
(D) 11
(E) Error: Cannot modify constant object
10. What will be output when you will execute
following c code?
#include<stdio.h>
int main(){
char a=250;
int expr;
expr= a+ !a + ~a + ++a;
printf("%d",expr);
return 0;
}
Choose all that apply:
(A) 249
(B) 250
(C) 0
(D) -6
(E) Compilation error
11. What will be output of following program?
#include<stdio.h>
int main(){
int a = 320;
char *ptr;
ptr =( char *)&a;
printf("%d ",*ptr);
return 0;
}
(A) 2
(B) 320
(C) 64
(D) Compilation error
(E) None of above
12. What will be output of following program?
#include<stdio.h>
int main(){
int i = 3;
int *j;
int **k;
j=&i;
k=&j;
printf("%u %u %d ",k,*k,**k);
return 0;
}
(A) Address, Address, 3
(B) Address, 3, 3
(C) 3, 3, 3
(D) Compilation error
(E) None of above
13. What will be output of following program?
#include<stdio.h>
#include<string.h>
int main(){
char *ptr1 = NULL;
char *ptr2 = 0;
strcpy(ptr1," c");
strcpy(ptr2,"questions");
printf("\n%s %s",ptr1,ptr2);
return 0;
}
(A) c questions
(B) c (null)
(C) (null) (null)
(D) Compilation error
(E) None of above
14. What will be output of following program?
#include<stdio.h>
#include<string.h>
int main(){
register a = 25;
int far *p;
p=&a;
printf("%d ",*p);
return 0;
}
(A) 25
(B) 4
(C) Address
(D) Compilation error
(E) None of above
15. What will be output of following program?
#include<stdio.h>
int main(){
int a = 10;
void *p = &a;
int *ptr = p;
printf("%u",*ptr);
return 0;
}
(A) 10
(B) Address
(C) 2
(D) Compilation error
(E) None of above
16. What will be output of following program?
#include<stdio.h>
#include<string.h>
int main(){
int register a;
scanf("%d",&a);
printf("%d",a);
return 0;
}
//if a=25
(A) 25
(B) Address
(C) 0
(D) Compilation error
(E) None of above
17. What will be output of following program?
#include<stdio.h>
int main(){
char arr[10];
arr = "world";
printf("%s",arr);
return 0;
}
(A) world
(B) w
(C) Null
(D) Compilation error
(E) None of above
18. What will be output of following program?
#include<stdio.h>
#include<string.h>
int main(){
int a,b,c,d;
char *p = ( char *)0;
int *q = ( int *q)0;
float *r = ( float *)0;
double *s = 0;
a = (int)(p+1);
b = (int)(q+1);
c = (int)(r+1);
d = (int)(s+1);
printf("%d %d %d %d",a,b,c,d);
return 0;
}
(A) 2 2 2 2
(B) 1 2 4 8
(C) 1 2 2 4
(D) Compilation error
(E) None of above
19. What will be output of following program?
#include<stdio.h>
#include<string.h>
int main(){
int a = 5,b = 10,c;
int *p = &a,*q = &b;
c = p - q;
printf("%d" , c);
return 0;
}
20. What will be output of following program?
#include<stdio.h>
int main(){
int i = 5 , j;
int *p , *q;
p = &i;
q = &j;
j = 5;
printf("%d %d",*p,*q);
return 0;
}
(A) 5 5
(B) Address Address
(C) 5 Address
(D) Compilation error
(E) None of above
21. What will be output of following c code?
void main()
{
struct employee
{
unsigned id: 8;
unsigned sex:1;
unsigned age:7;
};
struct employee emp1={203,1,23};
clrscr();
printf("%d\t%d\t
%d",emp1.id,emp1.sex,emp1.age);
getch();
}
22. What will be output of following c code?

void main()
{
struct bitfield
{
unsigned a:5;
unsigned c:5;
unsigned b:6;

}bit;
char *p;
struct bitfield *ptr,bit1={1,3,3};
p=&bit1;
p++;
clrscr();
printf("%d",*p);
getch();
}
23. What will be output of following c code?
#include<stdio.h>
extern int x;
int main(){
do{
do{
printf("%o",x);
}
while(!-2);
}
while(0);
return 0;
}
int x=8;
24. What will be output of following c code?
#include<stdio.h>
int main(){
int i=2,j=2;
while(i+1?--i:j++)
printf("%d",i);
return 0;
}
25. What will be output of following c code?
#include<stdio.h>
int main(){
int x=011,i;
for(i=0;i<x;i+=3){
printf("Start ");
continue;
printf("End");
}
return 0;
}
26. What will be output of following c code?
#include<stdio.h>
int main(){
int i,j;
i=j=2,3;
while(--i&&j++)
printf("%d %d",i,j);
return 0;
}
27. What will be output of following c code?
#include<stdio.h>
int r();
int main(){
for(r();r();r()) {
printf("%d ",r());
}
return 0;
}
int r(){
int static num=7;
return num--;
}
28. What will be output of following c code?
#include<stdio.h>
#define p(a,b) a##b
#define call(x) #x
int main(){
do{
int i=15,j=3;
printf("%d",p(i-+,+j));
}
while(*(call(625)+3));
return 0;
}
29. What will be output of following c code?
#include<stdio.h>
int main(){
int i;
for(i=10;i<=15;i++){
while(i){
do{
printf("%d ",1);
if(i>>1)
continue;
}while(0);
break;
}
}
return 0;
}
30. What will be output of following c code?

#include<stdio.h>
int main(){
int x=123;
int i={
printf("c" "++")
};
for(x=0;x<=i;x++){
printf("%x ",x);
}
return 0;
}

S-ar putea să vă placă și