MCQ of c programming (23 set question)



MCQ of c programming 1
Q. 1 . TurboC 3.0 is based on
a . DOS
b . UNIX
c . Windows
d . none
Q. 2 . Find the output.
void main()
{
int a=4,b=5;
printit(a, b);
}
printit(int b, int a)
{
printf("%d %d", a, b);
{
int a=0;
int b=1;
printf("%d %d", a, b);
}
}
a . 4 5 0 1
b . 5 4 0 1
c . 5 4 5 4
d . None of these
Q. 3 . Find the output
void main()
{
int const x=4;
int i,a[x]={1,2,3,4};
for(i=0;i<4;i++) x="1.5" y="1.5f" z="1.5" a="b="c="10;" a="10;" a="call(a="call(~a));" i="printf(" a="sizeof(int)/sizeof(float))" a="="1.000000)" a="{2.5};" b="a;" a="5,*p;" p="&a;" i="15;" x="16384,y="1;" ptr="&one_d;" i="1;i<="3;i++)" i="="3)" i="1;i<="3;i++)" i="="3)" p="Hai Bye" i="3;">0)
{
int i=5;
printf("%d",i);
i--;
}
}
a . 5 4 3 2 1
b . Error, multiple declaration for i
c . 3 2 1
d . Infinite loop
Q. 28 . The contents of a file will be lost if it is opened in
a . a mode
b . a- mode
c . w+ mode
d . a+ mode
Q. 29 . Find the output.
void main()
{
int i=1,j=2,k=3;
if(i==1)
if(j==2)
if(k==3)
{
printf("ok");
break;
}
else
printf("continue");
printf("bye");
}
a . ok
b . okbye
c . Misplaced break
d . None of these
Q. 30 . Find the output
void main()
{
printf("Lakshya\C\Academy");
}
a . LakshyaCAcademy
b . LakshyaAcademy
c . Lakshya
d . Lakshyacademy

MCQ of c programming 2



Q. 1 . Find out the output
void main()
{
int val=1234;
int *ptr=&val;
printf("%d %d",++val,(*(int *)ptr)--);
}
a . 1234 1233
b . 1235 1234
c . 1234 1234
d . None of these
Q. 2 . Find the correct output
void main()
{
int a=0;
for(a;++a;a<=100) printf("%d",a); } a . Print 1 to 99 infinite times b . Print 1 to 99 c . Print some garbage values d . Infinite loop Q. 3 . Find the output void main() { char c[6+4]="kill me"; printf("2%s",c); } a . ki b . me c . kill me d . 2kill me Q. 4 . Find out the output main() { int i=0; for(;i++;printf("%d",i)) ; printf("%d",i); } a . Infinite loop b . 0 1 c . 1 d . Stop after printing upto INT_MAX Q. 5 . Find out the output. int main(int k) { if(k<5) a="5,b="3,c="2;">b=2?z>3?1:2:3:4);
}
a . 1
b . 2
c . 3
d . 4
Q. 14 . Find the correct output
void main()
{
int i,j=6;
for(;i=j;j-=2)
printf("%d",j);
}
a . Error
b . Garbage values
c . 642
d . 6420
Q. 15 . State the correct statement.
a . In a while loop the control conditional check is performed n times.
b . In a do-while loop the control conditional check is performed n+1 times.
c . Break is a keyword used with if and switch case.
d . None of these.
Q. 16 . Find out the output
void main()
{
printf("3","%f",4);
}
a . 34.000000
b . 4
c . 3
d . Error
Q. 17 . What happens when subscript used for an array exceeds the array size?
a . Compiler gives an error message
b . Simply placed excess data outside the array
c . Simply placed excess data on top of other data or on the program itself.
d . The program must be compiled.
Q. 18 . The order of evaluation of operators having same precedence is decided by
a . Associativity rule
b . Precedence rule
c . Left-right rule
d . Right-left rule
Q. 19 . The set of routines stored in ROM that enable a computer to start the O.S and to communicate with the various devices in the system is known as
a . device driver
b . boot parameter
c . bios
d . none of these
Q. 20 . Find the output
struct main
{
int n;
int (*p)();
};
void main()
{
struct main m;
int fun();
m.p=fun();
*(m.p);
}
fun()
{
printf("Hallo");
}
a . Hallo
b . HalloHallo
c . Error
d . No output
Q. 21 . Find the output
union uni
{
int x;
int a:8;
char b:8;
}
void main()
{
union uni u={48};
printf("%d %c", u.a,u.b);
}
a . Invalid initialization
b . 48 0
c . 48 48
d . 0 0
Q. 22 . An AND gate
a . implements logical addition
b . is equivalent to a series switching circuit
c . implements logical subtractions
d . is equivalent to a parallel switching circuit
Q. 23 . Find the output
void main()
{
goto cite;
{
static int a=10;
cite: printf("%d",a);
}
}
a . 10
b . Warning, unreachable code
c . Error
d . Garbage value
Q. 24 . Find out the output
void main()
{
int i=3,j=2,k=1;
printf("%d / %d");
}
a . 1
b . 0
c . 3/2
d . 1/2
Q. 25 . The ‘continue’ statement is used to
a . Continue the next iteration of a loop construct.
b . Exit the block where it exists and continues after.
c . Exit the outermost block even if it occurs inside the innermost.
d . Continue the compilation even an error occurs in a program.
Q. 26 . which of the following declaration is incomplete type?
(1) struct tag;
(2) struct tag {int a };
(3) typedef struct{int a:}abc
a . 1 only
b . 1 and 2 only
c . 1 and 3 only
d . 2 and 3 only
Q. 27 . Find the odd one out
a . #elif
b . #line
c . #else
d . #ifdef
Q. 28 . The ‘continue’ statement is used to
a . Continue the next iteration of a loop construct.
b . Exit the block where it exists and continues after.
c . Exit the outermost block even if it occurs inside the innermost.
d . Continue the compilation even an error occurs in a program.
Q. 29 . What is the value of EOF which is declared in "stdio.h"?
a . 0
b . -1
c . Any positive value
d . None of these
Q. 30 . Which data type behaves like both integer type and character type?
a . short int
b . signed int
c . char
d . enum
MCQ of c programming 3


Q. 1 . Find the correct output
#include"string.h"
void main()
{
struct node
{
int data;
struct node *next;
};
struct node *p,*q;
p=(struct node *)malloc(sizeof(struct node));
q=(struct node *)malloc(sizeof(struct node));
p->data=10;
q->data=20;
p->next=q;
q->next=NULL;
printf("%d",p->data);
p=p->next;
printf("%d",p->data);
}
a . 10 20
b . 10 Garbage value
c . 20 Garbage value
d . None of these
Q. 2 . Find out the output
void main()
{
int x=2,*y=&x;
printf("%d",x*y);
}
a . 4
b . Garbage
c . Prints result of multiplication of address of x and x
d . Error
Q. 3 . Which of the following function is appropriate to read one character at a time?
a . fscanf()
b . fgetc()
c . read()
d . fgets()
Q. 4 . Find out the output
main()
{
const int x=get();
printf("%d",x);
}
get()
{
return(20);
}
a . 20
b . Garbage value
c . Error
d . 0
Q. 5 . Which format specifier is used to find out the offset address of a variable?
a . %o
b . %p
c . %h
d . %d
Q. 6 . Find out the output.
#define fool !1 - -1
void main()
{
printf("Hi!");
if (fool)
printf("Bye");
}
a . Lvalue required
b . Hi!
c . Bye
d . Hi!Bye
Q. 7 . Find out the output
void main()
{
char str[20];
static int i;
for(;;)
{
i++[str]= 'a'+15;
if(i==19)
break;
i++;
}
i[str]='\0';
printf("%s",str);
}
a . Error
b . Garbage value
c . p
d . pppppppppppppppppppp
Q. 8 . When loop looses its stop value then it is called
I. Odd loop
II. Even loop
III. Unknown loop
IV. User friendly loop
a . only I
b . I & III
c . III & IV
d . II & IV
Q. 9 . Find the correct output
void main()
{
int x=10,y=20,p,q;
p=add(x,y);
q=add(x,y);
printf("%d %d",p,q);
}
add(int a,int b)
{
a+=a;
b+=b;
return(a);
return(b);
}
a . 10 10
b . 20 20
c . 10 20
d . 20 10
Q. 10 . Find out the output
main()
{
int a[5] = {1,2,3,4,5};
int *ptr = (int*)(&a+1);
printf("%d %d" ,*(a+1),*(ptr-1));
}
a . 2 2
b . 2 1
c . 2 5
d . None of the above
Q. 11 . The area or scope of the variable depends on its
a . Date type
b . Storage class
c . System type
d . None of these
Q. 12 . Each case statement in switch is separated by
a . break
b . continue
c . exit()
d . goto
Q. 13 . Find out the output
main()
{
const int x=get();
printf("%d",x);
}
get()
{
return(20);
}
a . 20
b . Garbage value
c . Error
d . 0
Q. 14 . Find out the output
void main()
{
int a[5]={1,2,3};
int j;
for(j=0;j<5;j++) x1="5.74,x2="23.78;" x1="5.74" x2="23.78" opname =" Xstr(OP);" p="c;" p="lakshya" x="10;" x="callme(x);" i="5;" x="x/2-3;" s="’\dx’;" i="2;">>1)
{
default: i++;
case 1: ;
case 2: ;
}
printf("%d",i);
}
a . 2
b . 1
c . Expression syntax error
d . None of these
Q. 29 . Find the correct output
void main()
{
int a,b,c;
c=scanf("%d%d",&a,&b);
printf("\n%d",c);
}
a . 1
b . 2
c . 0
d . None of these
Q. 30 . Which of the following is known as auxillary memory?
a . RAM
b . ROM
c . HARD DISK
d . BIOS


MCQ of c programming 4


Q. 1 . Choose the wrong one
a . A structure can be nested within same structure
b . A value of one structure variable can be assigned to another structure variable
of same or different type.
c . It is illegal to use the structure itself as its member.
d . In self referential structure one member must be a pointer type.
Q. 2 . Find out the output
void main()
{
register int x;
scanf("%d",&x);
printf("%d",x);
}
If the value x is given 5 then output will be
a . 5
b . 0
c . Garbage
d . Error
Q. 3 . Find the output
#define float int
void main()
{
int x=10;
float y=3;
y=x%y;
printf("%f",y);
}
a . 0
b . 1
c . 1.000000
d . Error, floating point format not linked
Q. 4 . Which of the following is a miscellaneous directive?
a . #undef
b . #error
c . #elif
d . #include
Q. 5 . State the correct statement.
a . Linker combines different source files before compilation.
b . Linker combines different object files before execution.
c . Linker expands different source files before compilation.
d . none of these
Q. 6 . Find out the output.
void main()
{
int n=5;
if(n==5?printf("Hallo"):printf("Hai"),printf("Bye"));
}
a . HalloBye
b . Hallo
c . Expression syntax error
d . HaiBye
Q. 7 . Find the output
int x,y;
void main()
{
show(&x,&y);
printf("%d %d",x,y);
}
show(int *x,int *y)
{
*x++;
*y++;
}
a . 0 0
b . 1 1
c . Garbage output
d . None of these
Q. 8 . The different models used to organize data in the secondary memory are collectively called as
a . File structures
b . Data structures
c . Self referential structures
d . None of these
Q. 9 . Find the output
void main()
{
printf("%f",(float)9/5);
}
a . 1.8
b . 1.0
c . 2.0
d . None of these
Q. 10 . Find out the output
void main()
{
int static auto x;
x=5;
printf("%d",++x);
x--;
printf("%d",x);
}
a . Too many storage classes in declaration
b . 6 5
c . 6 6
d . None of these
Q. 11 . Find the output.
void main()
{
int x=5;
char a[x]={‘a’,’b’,’d’};
printf("%c",++1[a]);
}
a . b
b . c
c . d
d . None of these
Q. 12 . Addresses in Memory always stored in ABCD order but data is stored in
a . ABCD order
b . DCBA order
c . Depends on system type
d . None of these
Q. 13 . A bit field can be of
a . int
b . float
c . double
d . All of these
Q. 14 . The synonym for an existing data type can be created using
a . typedef
b . structure
c . enum
d . All of the above
Q. 15 . Which of the following is best suited for memory optimization
a . Union
b . Self referential structure
c . Array
d . Linked list
Q. 16 . Find out the output
#include"fcntl.h"
#include"sys\stat.h"
void main()
{
int x;
x=open("raja.txt",O_CREATO_TEXT, S_IWRITE);
printf("%d",x);
}
a . 5
b . 6
c . 7
d . None of these
Q. 17 . All structure variables are created in
a . Code area
b . Stack area
c . Uninitialized data area
d . Initialized data area
Q. 18 . Cast operator returns
a . Lvalue
b . Rvalue
c . Integral value
d . None
Q. 19 . Find the output
void main()
{
int i;
for(i=1;i<=3;i++) { print: printf("C"); printf("%d",i); } } a . Error,':' tag not allowed within the loop b . 1 2 3 c . C 1 C 2 C 3 d . Garbage value Q. 20 . Find the correct output void main() { int i=100; float f=5.413; print(i,f); } print(i,f) { printf("%d %f",i,f); } a . 100 5.413 b . 100 5.000 c . 100 0.000 d . Error Q. 21 . Find out the output void main(void) { char numbers[5][6]={"Zero","One","Two","Three","Four"}; int *ptr=(int *)numbers; for(;*ptr!=0;) printf("%c",*ptr++); } a . eoOeToTreFu b . Zero c . Zr d . Compile time error Q. 22 . Find out the output void main() { int a[]={1,2,3,4,5}; int j; for(j=0;j<5;j++) x="10,y;" y="choose(x);">=5)
return(y);
else
return(0);
}
a . 10
b . 0
c . Can’t determine
d . Error
Q. 24 . Find the correct output
#define div(x) x/x
void main()
{
printf("%d",div(16)*16);
}
a . 1
b . 16
c . 256
d . None of these
Q. 25 . What is the formula to find real address from 16-bit physical address?
a . segment address*16+offset address
b . segment address+offset address *16
c . segment address*10+offset address
d . segment address+offset address *10
Q. 26 . Which of the following function is appropriate to read one character at a time?
a . fscanf()
b . fgetc()
c . read()
d . fgets()
Q. 27 . Find the correct output
void main()
{
int a;
char b;
float c;
printf("%d",sizeof(a+sizeof(b+c));
}
a . 2
b . 1
c . 4
d . Error
Q. 28 . Find the output.
void main()
{
int x=5;
for (;x<=5;if(x==5)) printf("%d",++x); } a . 5 b . 6 c . Error d . No output Q. 29 . Find the output void main() { int i=-3,j=2,k=0,m; m=++i && j++ && ++k; printf("\n%d, %d, %d, %d",i,j,k,m); } a . -2,-3, 1,1 b . -3, 2, 0,1 c . -2, 3, 0,1 d . -2, 3, 1,1 Q. 30 . Find out the output. void main() { char *s="Rani"; printf("%s\r%s",s,s); } a . Rani b . RaniRani c . Rani\0 d . Ranii MCQ of c programming 5 Q. 1 . Choose the wrong one a . A structure can be nested within same structure b . A value of one structure variable can be assigned to another structure variable of same or different type. c . It is illegal to use the structure itself as its member. d . In self referential structure one member must be a pointer type. Q. 2 . Find out the output void main() { register int x; scanf("%d",&x); printf("%d",x); } If the value x is given 5 then output will be a . 5 b . 0 c . Garbage d . Error Q. 3 . Find the output #define float int void main() { int x=10; float y=3; y=x%y; printf("%f",y); } a . 0 b . 1 c . 1.000000 d . Error, floating point format not linked Q. 4 . Which of the following is a miscellaneous directive? a . #undef b . #error c . #elif d . #include Q. 5 . State the correct statement. a . Linker combines different source files before compilation. b . Linker combines different object files before execution. c . Linker expands different source files before compilation. d . none of these Q. 6 . Find out the output. void main() { int n=5; if(n==5?printf("Hallo"):printf("Hai"),printf("Bye")); } a . HalloBye b . Hallo c . Expression syntax error d . HaiBye Q. 7 . Find the output int x,y; void main() { show(&x,&y); printf("%d %d",x,y); } show(int *x,int *y) { *x++; *y++; } a . 0 0 b . 1 1 c . Garbage output d . None of these Q. 8 . The different models used to organize data in the secondary memory are collectively called as a . File structures b . Data structures c . Self referential structures d . None of these Q. 9 . Find the output void main() { printf("%f",(float)9/5); } a . 1.8 b . 1.0 c . 2.0 d . None of these Q. 10 . Find out the output void main() { int static auto x; x=5; printf("%d",++x); x--; printf("%d",x); } a . Too many storage classes in declaration b . 6 5 c . 6 6 d . None of these Q. 11 . Find the output. void main() { int x=5; char a[x]={‘a’,’b’,’d’}; printf("%c",++1[a]); } a . b b . c c . d d . None of these Q. 12 . Addresses in Memory always stored in ABCD order but data is stored in a . ABCD order b . DCBA order c . Depends on system type d . None of these Q. 13 . A bit field can be of a . int b . float c . double d . All of these Q. 14 . The synonym for an existing data type can be created using a . typedef b . structure c . enum d . All of the above Q. 15 . Which of the following is best suited for memory optimization a . Union b . Self referential structure c . Array d . Linked list Q. 16 . Find out the output #include"fcntl.h" #include"sys\stat.h" void main() { int x; x=open("raja.txt",O_CREATO_TEXT, S_IWRITE); printf("%d",x); } a . 5 b . 6 c . 7 d . None of these Q. 17 . All structure variables are created in a . Code area b . Stack area c . Uninitialized data area d . Initialized data area Q. 18 . Cast operator returns a . Lvalue b . Rvalue c . Integral value d . None Q. 19 . Find the output void main() { int i; for(i=1;i<=3;i++) { print: printf("C"); printf("%d",i); } } a . Error,':' tag not allowed within the loop b . 1 2 3 c . C 1 C 2 C 3 d . Garbage value Q. 20 . Find the correct output void main() { int i=100; float f=5.413; print(i,f); } print(i,f) { printf("%d %f",i,f); } a . 100 5.413 b . 100 5.000 c . 100 0.000 d . Error Q. 21 . Find out the output void main(void) { char numbers[5][6]={"Zero","One","Two","Three","Four"}; int *ptr=(int *)numbers; for(;*ptr!=0;) printf("%c",*ptr++); } a . eoOeToTreFu b . Zero c . Zr d . Compile time error Q. 22 . Find out the output void main() { int a[]={1,2,3,4,5}; int j; for(j=0;j<5;j++) x="10,y;" y="choose(x);">=5)
return(y);
else
return(0);
}
a . 10
b . 0
c . Can’t determine
d . Error
Q. 24 . Find the correct output
#define div(x) x/x
void main()
{
printf("%d",div(16)*16);
}
a . 1
b . 16
c . 256
d . None of these
Q. 25 . What is the formula to find real address from 16-bit physical address?
a . segment address*16+offset address
b . segment address+offset address *16
c . segment address*10+offset address
d . segment address+offset address *10
Q. 26 . Which of the following function is appropriate to read one character at a time?
a . fscanf()
b . fgetc()
c . read()
d . fgets()
Q. 27 . Find the correct output
void main()
{
int a;
char b;
float c;
printf("%d",sizeof(a+sizeof(b+c));
}
a . 2
b . 1
c . 4
d . Error
Q. 28 . Find the output.
void main()
{
int x=5;
for (;x<=5;if(x==5)) printf("%d",++x); } a . 5 b . 6 c . Error d . No output Q. 29 . Find the output void main() { int i=-3,j=2,k=0,m; m=++i && j++ && ++k; printf("\n%d, %d, %d, %d",i,j,k,m); } a . -2,-3, 1,1 b . -3, 2, 0,1 c . -2, 3, 0,1 d . -2, 3, 1,1 Q. 30 . Find out the output. void main() { char *s="Rani"; printf("%s\r%s",s,s); } a . Rani b . RaniRani c . Rani\0 d . Ranii MCQ of c programming 6 Q. 1 . How many times the loop will be executed? void main() { char c; for(c=1;c<=127;c++) printf("Lakshya"); } a . 127 times b . 126 times c . Only once d . None of these Q. 2 . Find the correct output void main() { int a[]={1,2,3,4,5}; int *p=(int *)(&a+1); printf("%d %d",*(a+1),*(p-1)); } a . 2 0 b . 1 0 c . 2 5 d . 1 garbage Q. 3 . Find the output void main() { char *p="hello"; printf ("%.3s", p); } a . hel b . llo c . 3hello d . None of these Q. 4 . put these stages of compilation in order, a) link b) compilation c) execute d) Precompilation a . a,b,c,d b . d,b,a,c c . d,c,b,a d . a,c,b,d Q. 5 . Find the correct output void main() { struct node { int data; struct node *link; }; struct node *p,*q; p=malloc(sizeof(struct node)); q=malloc(sizeof(struct node)); printf("%d %d",sizeof(p),sizeof(q)); } a . 4 4 b . 2 2 c . 1 1 d . None of these Q. 6 . Size of the physical address of 80x86 microprocessor is a . 16 bits b . 20 bits c . 24 bits d . 32 bits Q. 7 . Find the output void main() { int x=2,y=3,z; z=x++y++&&x++; printf("%d %d %d",x,y,z); } a . 3 3 1 b . 4 4 1 c . 4 3 1 d . None of these Q. 8 . Find the correct output void main () { for(clrscr();printf ("CITE");getch()) {} } a . Print CITE infinite times b . Print CITE for one time c . Print CITE as long as long as a keyboard is hit d . Print CITE for one time then print some garbage values. Q. 9 . Find out the output void paws(int *apple,int *ball) { *apple=*apple+*ball; *ball=*apple-*ball; *apple=*apple-*ball; } void main() { int apple=3617283450; int ball=3617283449; paws(&apple,&ball); printf("%d %d",apple,ball); } a . 23929 23930 b . 23322 23323 c . 23939 23940 d . Error Q. 10 . What happens when far address is incremented? a . Only segment address is incremented. b . Only offset address is incremented. c . Both segment and offset address are incremented. d . None of these Q. 11 . Find out the output void main() { char *p="rama"; char *q=0; char *r="\bsita"; strcpy(q,p); strcat(q,r); printf("%s",q); } a . ramsita b . ramasita c . rama\sita d . None of these Q. 12 . Find the output. void main() { int a=4,b=5; printit(a, b); } printit(int b, int a) { printf("%d %d", a, b); { int a=0; int b=1; printf("%d %d", a, b); } } a . 4 5 0 1 b . 5 4 0 1 c . 5 4 5 4 d . None of these Q. 13 . Find out the output. void main() { int a=5,b=7; int *p; p=&a; p--; *p=10; printf("%d %d",a,b); } a . 5 7 b . 5 10 c . 10 7 d . Garbage 7 Q. 14 . The address of all ISR is kept in a . IVT b . Page table c . Segmentation table d . None of these Q. 15 . Find the output. void main() { int x=5,y=6; do{ x=x+y; y=x-y; x=x-y; }while(x=0)
j++;
}
a . 5 times
b . 6 times
c . Infinite times
d . None of these
Q. 30 . Find out the output
void main()
{
printf("%u",main);
}
a . Garbage value
b . Run time error
c . Printing starting address of function main
d . Infinite loop
MCQ of c programming 7

Q. 1 . Find the correct output
1.#define p 2*2
2. void main()
3. {
4. #define p 4*4
5. printf("%d",p);
6. }
a . Error: In line no.1
b . Error: In line no.4
c . 4
d . 16
Q. 2 . Find the correct output
void main()
{
int p=7,q=9;
p=p^q;
q=q^p;
printf("%d %d",p,q);
}
a . 7 9
b . 9 7
c . 18 9
d . 14 7
Q. 3 . which of the following is a Manifest?
a . #define Lakshya 15
b . #defin Lakshya 15
c . #define Lakshya =15
d . #define Lakshya 15;
Q. 4 . Find out the output
void main()
{
float x=2.8,y=4;
if(x%=y)
printf("Both are equal");
else
printf("Not equal");
}
a . Both are equal
b . Not equal
c . Error
d . None of these
Q. 5 . Find the correct output
void main()
{
int a=2,b=0,c=-2;
if(b,a,c)
printf("Lack of C knowledge");
else
printf("Beginner");
}
a . Lack of C knowledge
b . Beginner
c . Compile time error
d . Run time error
Q. 6 . Find the correct output
#define SWAP(type,i,j) {type t=i;i=j;j=t;}
void main()
{
int s=5,t=2;
SWAP(int,s,t);
printf("%d %d",s,t);
}
a . 5 2
b . 2 5
c . 5 5
d . None
Q. 7 . Find the correct output
void main()
{
struct stu
{
int roll;
char name[10];
};
struct stu s={10,"Tuni"};
call(s);
}
call(struct stu s)
{
printf("%d %s",s.roll,s.name);
}
a . 10 Tuni
b . Compilation Error
c . Runtime Error
d . None of these
Q. 8 . Find the o/p
void main()
{
int x=5,y=3;
if(x>y)
printf("HOT");
else;
printf("COLD");
}
a . HOT
b . COLD
c . HOTCOLD
d . Compilation error
Q. 9 . The main function of shared memory is to
a . use primary memory efficiently.
b . do inter process communication.
c . do intra process communication.
d . none of these
Q. 10 . Switch case is very useful in
a . Yes-no problem
b . Menu-driven program
c . Game programming
d . All the above
Q. 11 . Find out the output.
#define PR(x) printf("%d ",x);
#define NULL printf("error");
#define PRINT(x1,x2) PR(x1); PR(x2); NULL
void main()
{
int x=5,y=10;
PRINT(x,y);
}
a . 5 10 error
b . 10 5 error
c . 5 10
d . 10 5
Q. 12 . Find the output
#define MAX(x,y) x>y?x:y
void main()
{
int x=2,y=3;
printf("%d",MAX(++x,++y));
}
a . 4
b . 5
c . Error
d . None of these
Q. 13 . Find out the output
void main()
{
unsigned int a=65536;
if(!a)
printf("%d",a,++a);
else
printf("%d",a,++a);
}
a . 0
b . 1
c . 65536
d . 65537
Q. 14 . x%y is equal to
a . y-(x/y)*x
b . x-(x/y)*y
c . x-(y/x)*x
d . y-(y/x)*y
Q. 15 . #define dprintf(e) printf(#e " = %d\n",'e')
void main()
{
int x=8;
int y=3;
dprintf(x/y);
}
a . expr=2
b . expr=101
c . x/y=101
d . None of the Above.
Q. 16 . Find out the output
void main()
{
int x=6,y=4,z=0;
if((x>=y)(z=y))
z-=2;
printf("%d",z);
}
a . 0
b . 2
c . -2
d . None of these
Q. 17 . Self referential structure
a . Used to create a memory link.
b . Plays an important role in linked list creation.
c . Contains the object of same structure which is of pointer type.
d . All the above
Q. 18 . Find out the output
typedef struct boy
{
float height;
char name:9;
int age:16;
}boy;
void main()
{
boy b={5.8,"Praveen kumar",24};
printf("%f %s %d",b.height,b.name,b.age);
}
a . 5.8 Praveen k 24
b . 5.8 Praveen kumar 24
c . 5.8 Praveen k 16
d . None of these
Q. 19 . Switch-case statement does not implement on
a . non exclusive case
b . mutually exclusive case
c . mutually non exclusive case
d . exclusive case
Q. 20 . Find out the output
void main()
{
unsigned int i=2;
i=(((i<<6)-1)^127); i="15;">y? x:y
void main()
{
int a,b;
a=MAX(1,2)+3;
b=MAX(4,3)+5;
printf("%d %d",a,b);
}
a . 5 4
b . 5 9
c . 5 8
d . None of these
Q. 24 . Find the output
void main()
{
*(char*)65=’a’;
printf ("%c",*(char*)65);
}
a . a
b . A
c . Error
d . None of these
Q. 25 . The function ftell(fp) returns
a . The beginning position of the file represented by fp.
b . The end position of the file represented by fp.
c . The current position of the file represented by fp.
d . None of these
Q. 26 . Find out the output
void paws(int *apple,int *ball)
{
*apple=*apple+*ball;
*ball=*apple-*ball;
*apple=*apple-*ball;
}
void main()
{
int apple=3617283450;
int ball=3617283449;
paws(&apple,&ball);
printf("%d %d",apple,ball);
}
a . 23929 23930
b . 23322 23323
c . 23939 23940
d . Error
Q. 27 . Find the correct output
void main()
{
char a[4]="rama";
char b[]="shyama";
printf("%d %d", sizeof(a),sizeof( b)) ;
}
a . 4 7
b . 5 6
c . 5 7
d . 4 6
Q. 28 . Find the correct output
typedef struct tag
{
int i;
char c;
}tag;
void main()
{
struct tag t1={1,’C’};
tag t2={2,’A’};
printf("%d%c ",t1.i,t1.c);
printf("%d%c ",t2.i,t2.c);
}
a . Error in first printf() statement.
b . Error in second printf() statement.
c . 1C 2A
d . None of these
Q. 29 . Find the correct output
void main()
{
int i=5;
i=++i + ++i + i++;
printf("%d",i);
}
a . 21
b . 22
c . 19
d . None of these
Q. 30 . What will be the value of ‘x’ after execution of the following program?
void main()
{
int x=!0*20;
}
a . 10
b . 20
c . 1
d . 0

MCQ of c programming 7


Q. 1 . Find the correct output
void main()
{
void show();
show();
}
void show()
{
char c[]="Lakshya\0\0";
int i,*p;
p=c;
for(i=0;*p;i++)
printf("%c",*p++);
}
a . Lakshya0
b . Lkha
c . Lkha0
d . Error
Q. 2 . Find the output
void main()
{
int x=2,y=3,z;
z=x++y++&&x++;
printf("%d %d %d",x,y,z);
}
a . 3 3 1
b . 4 4 1
c . 4 3 1
d . None of these
Q. 3 . An I/O stream is
a . a text stream
b . a binary stream
c . Both a and b
d . None of these
Q. 4 . Find out the output
void main()
{
int k=2,j=3,p=0;
p=(k,j,k);
k=p;
j=k;
printf("%d\n",p);
}
a . 2
b . Error
c . 0
d . 3
Q. 5 . Find the output.
void main()
{
int x=5,y=6;
change(&x, &y);
printf("%d %d", x, y);
}
change(int *x, int *y)
{
int temp=1;
temp^=*x;
*x^=*y;
*y^=temp;
}
a . 5 6
b . 6 5
c . 3 2
d . None of these
Q. 6 . Which of the following is an optical ROM?
a . ROM
b . PROM
c . EPROM
d . CDROM
Q. 7 . Find out the output
void e(int );
main()
{
int a;
a=3;
e(a);
}
void e(int n)
{
if(n>0)
{
e(--n);
printf("%d" , n);
e(--n);
}
}
a . 0 1 2 0
b . 0 1 2 1
c . 1 2 0 1
d . 1 2 0 1
Q. 8 . Find the output.
void main()
{
int array[]={1,3,5,7,9},*p,i;
p=array[0];
for(i=0;i<5;i++) c="65;" c="(!="c);" c="scanf(" y="Academy" i="3;i">=1;i--)
for(j=i;j>=1;j--)
printf("%d",i);
}
a . 321211
b . 333221
c . 332211
d . 123233
Q. 15 . Find the incorrect one for ‘typedef ’ srorage class
a . Permits descriptive names for datatypes.
b . Renaming existing datatype
c . Modification of the program is easier when host machine is changed.
d . All of the above
Q. 16 . Find the output
void main()
{
printf("%d %d",sizeof(‘a’), sizeof(‘a1’)) ;
}
a . 1 2
b . 1 1
c . 2 1
d . None of these
Q. 17 . Find the correct output
void main()
{
int a=2,b=4,c;
c=a>b?printf("2>=4"):puts("2<4");>=4
b . 2<4 a="100;" i="0;i<3;i++);" x="5;">
void main()
{
unsigned int a=-1;
printf("%d",~1);
}
a . -3
b . -1
c . -2
d . 1
Q. 29 . Which of the following is/are numeric type constants?
a . integer constant and character constant
b . integer constant and floating-point constant
c . character constant and floating-point constant
d . character constant and string constant
Q. 30 . Find the correct output
void main()
{
struct emp
{
int eid;
char ename[20];
};
struct emp e={010,"Deepak"};
show(s);
}
show(struct{int eid;char ename[20];}e)
{
printf("%d %s",e.roll,e.name);
}
a . Compilation Error
b . 010
c . 010 Deepak
d . None of these
MCQ of c programming 8

Q. 1 . void main()
{
int i,j;
for(i=0,j=0;i<2,j<2;i++,j++) i="5;" a="1,b="2;" a="="2)" b="="3)" x="2,y="3;" t="x;" x="*y;" y="t;" i="9;" i="0;i<3;i++)" x="3.7;" y="1.5;">1.5)
printf("fool");
else
printf("stupid");
}
a . fool
b . stupid
c . garbage value
d . None of these
Q. 11 . Most of the errors blamed on a computer are actually due to
a . programming errors
b . hardware damage
c . data entry errors
d . physical conditions
Q. 12 . Find the output.
void main()
{
int i;
for(i=-9;!i;i++);
printf("%d",-i);
}
a . 8
b . 9
c . 0
d . 1
Q. 13 . Switch-case statement does not implement on
a . non exclusive case
b . mutually exclusive case
c . mutually non exclusive case
d . exclusive case
Q. 14 . Find out the output.
void main()
{
int i=98;
while(100-i++)
printf("%u",i);
switch(i)
case ‘e’:
printf("Fool");
}
a . 98 99 100
b . 99 100
c . 99 100 Fool
d . Expression syntax error
Q. 15 . Find out the output
void main()
{
if("lakshya"=="lakshya")
printf("equal");
else
printf("not equal");
}
a . equal
b . not equal
c . Compile time error
d . None of these
Q. 16 . Find the output.
void main()
{
char s=’A’;
char a=’a’;
printf("%d",s-a);
}
a . -32
b . -18
c . Error
d . None of these
Q. 17 . Find out the true statement.
a . A union variable can be assigned to another union variable.
b . The address of union variable can be extracted by using & operator.
c . A function can return a pointer to the union.
d . All the above
Q. 18 . Find out the output
#define min(a,b) ((a)<(b))?(a):(b) main() { int i=0,a[20],*ptr; ptr=a; while(min(ptr++,&a[9])<&a[8]) i=i+1; printf("i=%d\n",i); } a . 7 b . 6 c . 5 d . compile time erro Q. 19 . To flush all output streams we can write a . fflush(stdout) b . fflush(NULL) c . fflush(ALL) d . None of these Q. 20 . Find the correct output void main() { int a[]={1,2,3,4,5},i; for(i=0;i<5;i++) p="hai" p="’H’;" q="’B’" a="10;" a="(*a)*(*a);" x="12;" y="x;" i="1;" c="’l’;" p="strchr(s,c);" x="(y="3,y+1);" a="5,b="4,c="10;">b) ? &a : &b) = (a+b>c);
printf("%d\t%d",a,b);
}
a . 5 4
b . Error, lvalue required
c . 0 4
d . 4 0
MCQ of c programming 9

Q. 1 . Find the correct output
void main()
{
int i;
for(i=1;i<=3;i++) { if(i==3) break; printf("%d",i); } for(i=1;i<=3;i++) { if(i==3) goto last; printf("%d",i); } end: ; } a . 123123 b . 1212 c . Error d . Garbage values Q. 2 . Which member of a union is in use at any time can be known explicitly using a . Enum b . Bit fields c . Static members d . Can’t be determined Q. 3 . The Turbo C implementation of C language supports a . High level file I/O b . System level file I/O c . Both a and b d . Executable files only Q. 4 . The commonly used functions for writing to a text stream are a . putc() b . fputc() c . fputs() d . All of the above Q. 5 . A bit field can be of a . int b . float c . double d . All of these Q. 6 . An assembler which runs on a computer for which it produces object codes is called as a . one pass assembler b . two pass assembler c . self assembler d . none of these Q. 7 . Find the output void main() { char a=’H’; switch(a) { case ‘H’:printf("%c",’H’); case ‘E’:printf("%c",’E’); case ‘L’:printf("%c",’L’); case ‘L’:printf("%c",’L’); case ‘O’: printf("%c",’O’); } } a . HELLO b . HEL c . Error d . HELO Q. 8 . Width of a data bus of the microprocessor is known as a . Byte Regs b . Word Regs c . WordLength d . None Q. 9 . Find the output void main() { char *p= (char*) 0x21; printf ("%d %p", p, p); } a . 21 0021 b . 21 21 c . 33 0021 d . None of these Q. 10 . In a hard disk a track is a collection of a . sectors b . clusters c . cylinders d . none of these Q. 11 . Find the output. void main() { int a=5; a=find(a+=find(a++)); printf("%d", a); } int find(int a) { return ++a; } a . 12 b . 13 c . 15 d . None of these Q. 12 . Find the correct output void main() { printf("%d","lakshya"[1]); } a . l b . a c . 97 d . None of these Q. 13 . Find the output. union res { int a:16; char b:10; } void main() { union res s; s.b=’B’; s.a=10; printf("%c %d", s.b, s.a) ; } a . 2048 10 b . B 2144 c . B 10 d . None of these Q. 14 . Find out the output. void main() { char *s="Rani"; printf("%s\r%s",s,s); } a . Rani b . RaniRani c . Rani\0 d . Ranii Q. 15 . Find the output void main() { int i; static int j=0; for(i=1;i<5;i++) num="345," sum="0;" m="num%10;" num="num/10;" sum="sum*10+m;" a="*a+*b;*b="*a-*b;*a="*a-*b;" x="10,y="20;" x=" %d" y =" %d\n" x="10" y="20" x="20" y="10" x="garbage" y="garbage" a="sizeof(int)/sizeof(float))" a="="1.000000)" i="10;" p="&i;" q="p;" a="2,b="4,c;" c="a">b?printf("2>=4"):puts("2<4");>=4
b . 2<4 x="16384,y="1;" i="3,j="3,k;" k="lakshya(++i)*++i;" p="a;" i="0;i<="2;i++)" j="2;printf(" c="a;" i="1;i<5;i++)" s="{80," a="3,b="6;" a="b);" x="10;" y="3.14;" x="20;" a="4,b="5,ar[2];" f="0.9;" d="0.9f;" f="="d)" i="1,j="2,k="3;" i="="1)" j="="2)" k="="3)" p="array[0];" i="0;i<5;i++)" i="4;i">0;)
printf("%d",a[i--]);
}
a . 05432
b . 54321
c . 5432
d . 4321
Q. 26 . Which of the following is/are true for nested if
I. It can only test for equality.
II. Conditions may be repeated for number of times.
III. It can evaluate relational or logical expressions.
IV. Character constants are automatically converted to integers.
a . All of the above
b . I & II
c . I, II & III
d . II, III & IV
Q. 27 . Most of the errors blamed on a computer are actually due to
a . programming errors
b . hardware damage
c . data entry errors
d . physical conditions
Q. 28 . Find the correct output
struct abc
{
int x;
char c;
union xyz
{
int a;
char b;
float c;
}p;
}q;
void main()
{
printf("%d",sizeof(q));
}
a . 2
b . 4
c . 7
d . None of these
Q. 29 . Find the output
void main()
{
int *q,**p,x=4;
q=&x;
p=&q;
(**p)++;
++*p;
printf("%d",**p);
}
a . 5
b . 6
c . Garbage output
d . Error, non portable pointer conversion
Q. 30 . Which storage class can precede any data type in the parameter list?
a . Auto
b . Static
c . Register
d . Extern


MCQ of c programming 11



Q. 1 . Find the output
void main()
{
int i=4,j=-3;
mul(&i,j);
printf("%d %d",i,j);
}
mul(int *a,int b)
{
a=*a**a;
b=b*b;
}
a . 4 3
b . 4 9
c . 16 -3
d . 16 9
Q. 2 . Find the output.
void main()
{
unsigned long i=40000;
printf("%l", i);
}
a . %l
b . 40000
c . Garbage
d . No output
Q. 3 . Find out the output
void main()
{
static int x=4,y=5;
callme(x,y);
}
callme(static int x,static int y)
{
x=y;
y=x;
printf("%d %d",x,y);
}
a . 4 5
b . 5 5
c . Error
d . None of these
Q. 4 . State the correct statement.
a . Nested union is not possible.
b . Self referential union is possible
c . Different interpretations for the same memory location are possible in structure.
d . Both a and c
Q. 5 . Find out the output
void main()
{
printf("%d",(4,7,11)-(6,5,12));
}
a . 5
b . -2
c . -1
d . None of these
Q. 6 . Find out the output
void main()
{
int i=0;
((i--,++i)!=0);
i-=i++;
i+=i++;
printf("i=%d",i);
}
a . 3
b . 2
c . 1
d . Error
Q. 7 . The default initial value of malloc() memory allocation is
a . Garbage
b . Zero
c . Can’t say
d . None of these
Q. 8 . Which of the file extensions is used as executable file?
a . .EXE
b . .COM
c . .BAT
d . all the above
Q. 9 . Find the output
#define ABC(x) printf("%d",x);\
printf("%0",x);
void main()
{
int x=12;
ABC(x)
}
a . 1214
b . 1212
c . 12
d . Error
Q. 10 . Find the output.
void main()
{
int array[]={1,3,5,7,9},*p,i;
p=array[0];
for(i=0;i<5;i++) a="15;" date="{&a," p="&date;">p);
10. }
a . Line no.8
b . Line no. 9
c . Line no.6
d . None
Q. 12 . Find the correct output
void main()
{
int a=2,b=5;
if(a,b,0)
printf("Norton");
else
printf("Avast");
}
a . Norton
b . Avast
c . Compilation error
d . None of these
Q. 13 . Find the output
void main()
{
while(!"")
{
printf("Hello");
}
}
a . Prints Hello infinite times
b . Hello
c . Error
d . No output
Q. 14 . Find out the output
void main()
{
char a[]="abcde";
char *p=a;
p++;
p++;
p[2]='z';
printf("%s",p);
}
a . zde
b . cdz
c . abzde
d . abz
Q. 15 . Find the correct output
void main()
{
char a[][9]={"Lakshya","Advance","C","Training","Java"};
printf("%c %s in %s",a[2][0],&a[3][0],&a[0][0]);
}
a . CT in L
b . C in Lakshya
c . C Training in Lakshya
d . Error
Q. 16 . The pointer which is created in data segment and holds the address of base location is known as
a . Near pointer
b . Bad pointer
c . Smart pointer
d . None of these
Q. 17 . State the correct statement.
a . A for loop may be nested in a while loop.
b . A do-while loop may be nested in a for loop
c . A while loop may be nested in a for loop
d . All the above
Q. 18 . Find out the output
void main()
{
int a=1,b=2,c=3;
scanf("%d %*d %d",&a,&b,&c);
printf("a=%d b=%d c=%d",a,b,c);
}
[ NOTE : 3 values entered by the user are:100 200 300 ]
a . a=1 b=2 c=3
b . a=100 b=200 c=300
c . a=100 b=200 c=3
d . a=100 b=300 c=3
Q. 19 . What is the format specifier of long double?
a . %ld
b . %id
c . %lf
d . %g
Q. 20 . What is the format specifier of long double?
a . %ld
b . %id
c . %lf
d . %g
Q. 21 . Find the correct output
void main()
{
int i=1;
i=(5>2)?printf(""Rama):printf("Shyama");
printf("%d",i);
}
a . Rama1
b . Rama4
c . Rama0
d . None of these
Q. 22 . int far **p, here p is a
a . Far pointer holds address of another far pointer.
b . Near pointer holds address of another far pointer.
c . Far pointer holds address of another near pointer.
d . Near pointer holds address of another near pointer.
Q. 23 . Find out the output
void main()
{
int i;
char *p="lakshya",c;
while(i++printf?"cool":"fool");
}
a . cool
b . fool
c . No output
d . None of these
Q. 30 . Find the correct output
void main()
{
int a=0;
for(a;++a;a<=100) printf("%d",a); } a . Print 1 to 99 infinite times b . Print 1 to 99 c . Print some garbage values d . Infinite loop MCQ of c programming 12 Q. 1 . Find out the output #include"limits.h" void main() { printf("%d",sizeof(-INT_MIN)); } a . 0 b . 2 c . 32768 d . 65536 Q. 2 . Find the correct output union yyy { int i; float f; }y; void main() { y.i=23.786; printf("%d",y.i); } a . Error b . Garbage c . 23 d . None of these Q. 3 . Find out the output. int a=6; void main() { static int *x=&a; printf("%d",*x); } a . 6 b . 0 c . Error, illegal initialization d . None of these Q. 4 . Find the output void main() { int x=5; if(x=1) printf("one"); else printf("five"); printf("%d",x); } a . One5 b . Five5 c . One1 d . Five1 Q. 5 . Find the output. void main() { char ch; if("printf("")") printf("Ok"); else printf("Bye"); } a . Ok b . Bye c . 0Ok d . 0Bye Q. 6 . Find the correct output void main() { int i=5; i=++i + --i - ++i; printf("%d",i); } a . 6 b . 7 c . 5 d . None of these Q. 7 . Find the correct output void main() { int i; float f=3.14; float compute(float); i=compute(f); printf("%d",i); } float compute(float x) { if(x==3.14) return(0); else return(1); } a . Suffering b . Garbage c . 0 d . 1 Q. 8 . Find the correct output #define mul(x,y) x*y void main() { int a=5,b=6; printf("%d",mul(a+1,b-1)); } a . 10 b . 30 c . 35 d . None of these Q. 9 . Find out the output void main() { show(5); } show(int x) { static int i=1; while(i++<5) x="5;" x="="5))" y="5;" x="come(y);" y="go(x);" p="x+3;" q="5;r="4;">r)-2]);
}
a . 4
b . 3
c . 5
d . Error
Q. 17 . The errors that can be pointed out by the compiler are
a . syntax error
b . semantic error
c . logical error
d . all the above
Q. 18 . Find the o/p
struct date
{
int day,month,year;
}
void main()
{
struct date today={3,7,6,2007};
printf("%d %d %d",today.day,today.month,today.year);
}
a . 3 7 6
b . 7 6 2007
c . Compilation error
d . None of these
Q. 19 . Maximum range of an integer
a . MAX_MAX
b . INT_MAX
c . SIZEOF_INT
d . MAX_INT
Q. 20 . Find the output
void main()
{
int *p,**q,i=5;
p=&i;
q=p;
**q=10;
printf ("%d %d",*p,**q);
}
a . 5 10
b . 10 10
c . 5 5
d . None of these
Q. 21 . Recursion
a . Execution is faster.
b . Additional storage space is not required.
c . A queue is needed to process the recursion.
d . Helps in writing compact code.
Q. 22 . Find out the false statement.
a . The function main() returns an integer by default.
b . A function can be a part of an expression.
c . Size of a function can be measured using sizeof() operator.
d . A stack frame is created in memory for each function call.
Q. 23 . 80x86 Microprocessor wordlength is of
a . 8 bits
b . 16 bits
c . 24 bits
d . 32 bits
Q. 24 . What is the octal equivalent of a decimal number (179)10
a . (263)8
b . (363)8
c . (163)8
d . (463)8
Q. 25 . Find the output.
struct st
{
int roll;
char name[15];
}s{10,"lakshya"};
void main()
{
printf("%d %s", (&s)->roll,(&s)->name);
}
a . 15 lakshya
b . Garbage lakshya
c . Garbage garbage
d . None of these
Q. 26 . If float and double are defined with type register the compiler treats them as
a . Auto variables
b . Static variables
c . Register variables
d . Extern variables
Q. 27 . Find the correct output
void main()
{
struct dist
{
char *c;
int i;
struct dist *d;
};
static struct dist arr[]={{"Raipur",1,arr+1},
{"Kolapur",2,arr+2},
{"Bhabanipur",3,arr}
};
struct dist *dis=arr;
printf("%s",arr[(++dis)->i].c);
}
a . Kolapur
b . Raipur
c . Bhabanipur
d . aipur
Q. 28 . Find out the output
void main()
{
char a[10]="lakshya";
int i=0,j=0;
while(i<=strlen(a)) { i=j++; if(a[i]==’a’a[i]==’e’a[i]==’i’a[i]==’o’a[i]==’u’) { while(ip);
10. }
a . Line no.8
b . Line no. 9
c . Line no.6
d . None



Q. 1 . Find the output
void main()
{
int x=5, *p, q;
p=&x;
q=p;
printf ("%d", ++*q);
}
a . 5
b . 6
c . Error, invalid indirection
d . None of these
Q. 2 . B language was developed by
a . Dennis Ritchie in 1972
b . Martin Richards in 1967
c . Geoffrey brown in 1968
d . Ken Thompson in 1970
Q. 3 . Find the output
#define float int
void main()
{
int x=10;
float y=3;
y=x%y;
printf("%f",y);
}
a . 0
b . 1
c . 1.000000
d . Error, floating point format not linked
Q. 4 . Find the correct output
void main()
{
int i;
float f=3.14;
float compute(float);
i=compute(f);
printf("%d",i);
}
float compute(float x)
{
if(x==3.14)
return(0);
else
return(1);
}
a . Suffering
b . Garbage
c . 0
d . 1
Q. 5 . The PID of the kernel process is
a . 0
b . 1
c . undefined
d . 2
Q. 6 . Which operator is used both as an operator and a keyword?
a . Conditional operator
b . Cast operator
c . Sizeof operator
d . None of these
Q. 7 . Find the correct output
void main()
{
int x=0;
printf(x+"YUinlakshya%d",x=1);
}
a . 1
b . YUinlakshya1
c . Uinlakshya1
d . Uinlakshya1
Q. 8 . Find the correct output
#define int char
void main()
{
int a=65;
printf("%d",sizeof(a));
}
a . 1
b . 2
c . Garbage value
d . None of these
Q. 9 . Choose the appropriate one.
A variable is called as
a . Lvalue
b . Modifiable lvalue
c . Rvalue
d . Modifiable rvalue
Q. 10 . Find the output
void main()
{
char x=’A’;
switch(x)
{
if(x==A)
{
printf("tomtom");
}
else
{
printf("tom");
default:printf("harry");
}
}
}
a . tomtom
b . harry
c . tomharry
d . Error
Q. 11 . Find out the output
int j=10;
void main()
{
int j=5;
static int i;
i=j;
printf("%d",i);
}
a . 5
b . 10
c . Error, illegal initialization
d . None of these
Q. 12 . Find out the output
void fun(char**);
main()
{
char * argv[] = { "ab" ,"cd" , "ef" ,"gh", "ij" ,"kl" };
fun( argv );
}
void fun( char **p )
{
char* t;
t= (p+= sizeof(int))[-1];
printf( "%s" , t);
}
a . ab
b . cd
c . ef
d . gh
Q. 13 . Find the correct output
void main()
{
char *p="abc123",*q="abc";
while(*p++=*q++)
printf("%c%c",*p,*q);
}
a . aabbcc
b . bbcc112233
c . bbcc1
d . aabbcc123
Q. 14 . Find the correct output
void main()
{
char s[]="Lakshya";
printf("%c",*&*s);
}
a . Error
b . Garbage value
c . No output
d . L
Q. 15 . Find out the output
void main()
{
int a= 0;int b = 20;char x =1;char y =10;
if(x,b--,x--,x++)
printf("%d",x);
}
a . 0
b . 1
c . 2
d . None of the above
Q. 16 . Find the correct output
void main()
{
int a=9;
char c;
c=2*20.5+a;
printf("%c",c);
}
a . a
b . b
c . 9
d . Error
Q. 17 . Find the output
void main()
{
int x=65536,y;
y=sizeof(++x);
printf("%d %d",x,y);
}
a . 0 2
b . 1 2
c . 65536 2
d . None of these
Q. 18 . Find out the output
void 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 . ck
b . te
c . violet
d . Error
Q. 19 . A bit field is
a . A pointer variable in a structure
b . One bit or a set of adjacent bits within a word.
c . A pointer variable in a union.
d . None of these
Q. 20 . Find out the output
void main()
{
int x=10;
x=callme(x);
printf("%d",x);
}
callme(int x)
{
int i=5;
x=x/2-3;
return x,i;
}
a . 3
b . 5
c . Can’t return more than one value
d . Function should have a return type
Q. 21 . Find the output.
void main()
{
int x=5;
void *p;
p=&x;
printf("%d",*(int *)p);
}
a . 5
b . Garbage
c . Generic pointer can not be dereferenced
d . No output
Q. 22 . Find the output
union res
{
char a:6;
int b:8;
}
void main()
{
union res s;
printf("%d",sizeof(s));
}
a . 14
b . 8
c . 1
d . 2
Q. 23 . The function call fseek(ptr,0,0),is same as
a . ptr=rewind(ptr)
b . ptr=fopen()
c . ftell(ptr)
d . None of these
Q. 24 . Find out the output
#define CUBE(x) (x*x*x)
main()
{
int a=3; char *b;
b=&a;
a=CUBE(*b++);
printf("\n %d %d",a,b);
}
a . 64 4
b . 27 4
c . 27 6
d . None of these
Q. 25 . Find the correct output
void main()
{
int i=5;
i=i++ + ++i + i++;
printf("%d",i);
}
a . 18
b . 20
c . 24
d . None of these
Q. 26 . Find out the output
int main(void)
{
int x=256;
if (*(char *)&x == 255)
{
printf("Little Endian\n");
}
else
{
printf("Big Endian\n");
}
return 0;
}
a . Big Endian
b . Little Endian
c . Error
d . None of these
Q. 27 . Find out the output.
struct xyz
{
int xyz ;
}xyz;
union xyz
{
int xyz;
}xyz;
void main()
{
printf("%d ",xyz.xyz);
}
a . 1
b . 0
c . compile time error
d . None of these
Q. 28 . Find out the output
void main()
{
char s[]="Lakshya";
printf("%c %c",*(&s),*(&s[0]));
}
a . L L
b . Prints character present at whole address of s, then L
c . La
d . Error, lvalue required
Q. 29 . Which of the following is a valid hexadecimal integer constant?
a . -0xa
b . 0x5.2
c . 0xIF
d . all of the above
Q. 30 . The function call fseek(ptr,0,0),is same as
a . ptr=rewind(ptr)
b . ptr=fopen()
c . ftell(ptr)
d . None of these

MCQ of c programming 14


Q. 1 . Find the correct output
void main()
{
int a=30,b=20,c;
c=(float)a/b;
printf("%d",c);
}
a . 1
b . 1.500000
c . 1.000000
d . Error
Q. 2 . State the correct statement.
struct employee
{
int eid;
char name[23];
float salary;
}emp={278,"p.das",5000.000},*p=&emp;
How to access eid in the above structure?
I. *p->eid II. p.eid III. (*p).eid IV. (*p)->eid
a . Only I
b . Only III
c . Both I & III
d . All of the above
Q. 3 . Find out the output
void main()
{
int ch=48;
if(ch)
{
printf("valid");
break;
}
else
printf("invalid");
}
a . valid
b . invalid
c . No output
d . None of these
Q. 4 . Find out the output
void main()
{
int k=1;
printf("%d==1 is ""%s",k,k==1?"TRUE":"FALSE");
}
a . Error
b . 1==1 is TRUE
c . 0==1 is FALSE
d . Garbage Output
Q. 5 . what is the o/p in turbo compiler?
struct stud
{
int x:18;
char *y;
f loat z;
}s1;
void main()
{
printf("%d",sizeof(s1));
}
a . 7
b . 1
c . 8
d . Error
Q. 6 . Find the output
void main()
{
int i=-3,j=2,k=0,m;
m=++ && j++ && ++k;
printf("\n%d, %d, %d, %d",i,j,k,m);
}
a . -2,-3,1,1
b . -3, 2, 0,1
c . -2, 3, 0,1
d . -2, 3, 1,0
Q. 7 . Find the output.
void main()
{
int x=5,y=6;
do{
x=x+y;
y=x-y;
x=x-y;
}while(x0)
rev(--n);
printf("%d",n);
}
a . 0012
b . 123
c . 012
d . None of these
Q. 9 . RAM is made up of
a . registers
b . diodes
c . capacitors
d . flip-flops
Q. 10 . The default memory model in C is
a . tiny
b . small
c . medium
d . compact
Q. 11 . Find the correct output
void main()
{
int i=5;
i=i++ + ++i;
printf("%d",i);
}
a . 11
b . 12
c . 13
d . None of these
Q. 12 . Find out the output
int i = 4;
void main()
{
switch (i)
{
default:
;
case 3:
i += 5;
if ( i == 8);
{
i++;
if (i = 9);
i *= 2;
}
i -= 4;
break;
case 8:
i += 5;
break;
}
printf("i = %d\n", i);
}
a . i=5
b . i=16
c . i=18
d . i=14
Q. 13 . Find out the output.
void main()
{
printf("%d",sizeof(5.3));
}
a . 2
b . 4
c . 8
d . Suffering
Q. 14 . A file pointer is
a . a stream pointer
b . a buffer pointer
c . a pointer to a FILE data type
d . All of the above
Q. 15 . Find out the output
void main()
{
char p[6];
static char *q;
q=p;
*q="Hello";
printf("%s",q);
}
a . Garbage output
b . Hello
c . Error
d . None of these
Q. 16 . Find out the output
void main()
{
int x[]={1,2,3,4,5,6};
int *p,q,r;
p=x+3;
q=5;r=4;
printf("%d",p[(q>r)-2]);
}
a . 4
b . 3
c . 5
d . Error
Q. 17 . What is the formula to find real address from 16-bit physical address?
a . segment address*16+offset address
b . segment address+offset address *16
c . segment address*10+offset address
d . segment address+offset address *10
Q. 18 . The function strcmp(s1,s2) returns negative value if
a . Length of s1 is less than s2
b . Length of s2 is less than s1
c . Length of s1 is less than or equal to s2
d . Both s1 and s2 are same.
Q. 19 . Find the output.
void main()
{
int a,b,sum=0;
sum= (a=5,b=9,++a+ ++b);
printf("%d", sum);
}
a . 16
b . 5
c . Expression syntax error
d . Error, lvalue required
Q. 20 . Find out the output
#define Str(x) #x
#define Xstr(x) Str(x)
#define OP plus
void main()
{
int *opname = Xstr(OP);
printf("%s",opname);
}
a . plus
b . No output
c . It will show compilation error
d . No output
Q. 21 . void main() { int i,j=1; for(i=1;i<5;i++) i="="2" j="="2)" i="1;" i="="2)" x="5;" temp="a;" a="b;" b="temp;" a="5,b="6,temp;"> b)
swap(a,b);
printf("a=%d b=%d",a,b);
}
a . a=5 b=6
b . a=6 b=5
c . a=6 b=0
d . None of these
Q. 26 . Find out the output
main()
{
static int val=7;
int data;
if (--val)
{
data=main()+val;
printf("%d ",data);
}
return 0;
}
a . Compile time Error
b . Infinite loop
c . 1 2 3 4 5 6
d . 0 0 0 0 0 0
Q. 27 . Find out the output.
void main()
{
int i=5,j=5;
i= i++*i++*i++*i++;
printf("i=%d ",i);
j= ++j*++j*++j*++j;
printf("j=%d",j);
}
a . i=1680 j=1680
b . i=629 j=6561
c . i=1681 j=3024
d . Compile time Error
Q. 28 . State the true statement.
a . A circular list doesn’t have a natural first or last node.
b . It is always desirable keep an extra node at the front of the list.
c . A stack can’t be represented in memory using linear array.
d . All of the above
Q. 29 . Find the output
#define float int
void main()
{
int x=10;
float y=3;
y=x%y;
printf("%f",y);
}
a . 0
b . 1
c . 1.000000
d . Error, floating point format not linked
Q. 30 . Find the output
void main()
{
int *q,**p,x=4;
q=&x;
p=&q;
(**p)++;
++*p;
printf("%d",**p);
}
a . 5
b . 6
c . Garbage output
d . Error, non portable pointer conversion
MCQ of c programming 15


Q. 1 . Find the output.
void main()
{
int x[5];
see(x);
printf("%d",x[2]);
}
see(int x[])
{
x++;
x[1]=100;
}
a . 100
b . 0
c . Garbage
d . None of these
Q. 2 . Which storage class can precede any data type in the parameter list?
a . Auto
b . Static
c . Register
d . Extern
Q. 3 . ftell()
a . Takes only one argument
b . Takes two arguments
c . Moves the file pointer only in forward direction
d . None of these
Q. 4 . The operators [],.,-> are known as
a . Data access operators
b . Structure access operators
c . Member access operators
d . None of these
Q. 5 . What is not possible with union?
a . Array of union
b . Pointer to union
c . Self-referential union
d . None of these
Q. 6 . Find out the output
main()
{
char str[5]="fast";
static char *ptr_to_array = str;
printf("%s",ptr_to_array);
}
a . Compilation will only give a warning but will proceed to execute & will
display "fast"
b . Display "fast" on screen
c . Error illegal initialization
d . None of the above
Q. 7 . Find the correct output
void main()
{
struct dist
{
char *c;
int i;
struct dist *d;
};
static struct dist arr[]={{"Raipur",1,arr+1},
{"Kolapur",2,arr+2},
{"Bhabanipur",3,arr}
};
struct dist *dis=arr;
printf("%s",arr[(++dis)->i].c);
}
a . Kolapur
b . Raipur
c . Bhabanipur
d . aipur
Q. 8 . Find the output
void main()
{
enum color{red, green};
enum colors{green,white};
printf("%d %d",green, white);
}
a . 1 1
b . 0 1
c . 1 0
d . None of these
Q. 9 . The function unlink(filename) is used
a . to remove link between file and buffer
b . to remove the existing file from the directory
c . to remove the contents of file only
d . None of these
Q. 10 . Find the output
void main()
{
int i=5;
for(i=-5; !!i; i++);
printf("%d",-i)
}
a . 5
b . 0
c . -5
d . None of these
Q. 11 . Find the output
void main()
{
int x=1;
do{
printf(‘a’);
x++;
}while(x<5); x="65535;x">=1;x++)
printf("no output");
}
a . no output
b . Prints no output infinite times
c . No output
d . None of these
Q. 15 . Find out the output.
void main()
{
int val=2;
val = - --val- val-- - --val;
printf("%d",val);
}
a . Compile time Error
b . 3
c . -1
d . 0
Q. 16 . Find the output.
void main()
{
int i=65,j=0;
for(j;j<4;j++) a="5,c;" b="6;;" c="a+b;" today="{3,7,6,2007};" num="345," sum="0;" m="num%10;" num="num/10;" sum="sum*10+m;" ch="{‘a’,’b’,’c’,’" x=" -350u;" y=" -145u;" p="hai" p="’H’;" q="’B’" str= "lakshya" x="-17">>2;
printf ("%d", x);
}
a . -3
b . 3
c . -5
d . 7
Q. 13 . Find out the output
main()
{
int i=-3,j=2,k=0,m;
m=++i&&++j++k;
printf("\n %d %d %d %d",i,j,k,m);
}
a . -2 3 0 1
b . -3 2 0 1
c . -2 3 1 1
d . Error
Q. 14 . Find the correct output
void main()
{
int *p,*q,*r;
q=(int *)malloc(sizeof(int));
p=q-1;
r=q+1;
*p=100;
*q=200;
*r=300;
p++;
q++;
printf("%d %d",*p,*q);
}
a . 10 20
b . 20 20
c . 20 30
d . 30 30
Q. 15 . Find the correct output
struct byte
{
int a:2;
int b:1;
int c;
};
void main()
{
struct byte d;
printf("%d",sizeof(d));
printf("%d",sizeof(d.a));
}
a . 4 1
b . 3 1
c . Error
d . None of these
Q. 16 . Find out the output
void main()
{
printf("\/\*\-*\/");
}
a . Run time Error
b . \/*-*\/
c . /*-*/
d . None of these
Q. 17 . Find the output.
void main()
{
char ch=’\356’;
printf("%d",ch);
}
a . -18
b . 18
c . Error
d . 51
Q. 18 . Find the correct output
void main()
{
char *p="CITE";
char *q;
q=(char *)malloc(sizeof(p));
while(*p++=*q++);
printf("%s",q);
}
a . CITE
b . ITE
c . Empty string
d . None of these
Q. 19 . During linking the linker adds more information in the header of the executable file, known as
a . link parameter
b . load parameter
c . program segment prefix
d . dynamic link library
Q. 20 . Character constant is 2 byte long to represent
a . hexadecimal constant
b . octal constant
c . both octal & hexadecimal constant
d . none of these
Q. 21 . Find the correct output
void main()
{
int x;
x=compute(4);
printf("%d",x);
}
int compute(int n)
{
if(n<=1) return 2; else return(compute(n-2)*compute(n-1)); } a . 10 b . 8 c . 16 d . 32 Q. 22 . Find the correct output #include"string.h" #include"alloc.h" void main() { struct linklist { int item; struct node *link; }; struct linklist *p,*q; p=(struct linklist *)malloc(sizeof(struct linklist)); q=(struct linklist *)malloc(sizeof(struct linklist)); p-> item=10;
q-> item=20;
p-> link=q;
q-> link=p;
while(p)
{
printf("%d",p->item);
p=p->link;
}
}
a . 101010……….
b . 10201020……..
c . 202020………..
d . None of these
Q. 23 . Unary operators are
a . Operator dependant
b . Position dependant
c . Value dependant
d . Both b and c.
Q. 24 . Find out the output.
void main()
{
char c=65;
c=(!=c);
printf("%d",c);
}
a . 0
b . 65
c . 1
d . 66
Q. 25 . The secret signature of Borland International (in Turbo C 3.0) is kept in
a . data area
b . code area
c . text area
d . none of these
Q. 26 . Stack is useful for implementing
a . Recursion
b . Breadth first search
c . Both a and b
d . None of these
Q. 27 . State the true statement.
‘void ‘ is an empty data type associated with
a . all aggregate types
b . all data types
c . all functions and pointers
d . all the above
Q. 28 . Find out the output
void main()
{
char *s[]={"utpal","bubu"};
printf("%c %s",*name[0],name[1]);
}
a . u bubu
b . u garbage
c . garbage bubu
d . None of these
Q. 29 . Find the correct output
void main()
{
int i=5;
enum vehicle{car=i,bike,scooter};
printf("%d",car);
}
a . 0
b . 5
c . Error
d . None of these
Q. 30 . A unit of 8 bits is known as byte in same way a unit of 4 bits is known
a . half byte
b . ribble
c . nibble
d . none of these
MCQ of c programming 17

Q. 1 . Find out the output
void main()
{
int x,y;
*(&x)=10;
*(&y)=13;
printf("won%cder%c",y,x);
}
a . der
b . won13der13
c . won1der1
d . won
der
Q. 2 . Find the correct output
void main()
{
struct place
{
char *str;
int i;
struct place *ptr;
};
static struct place a[]={{"Raipur",1,arr+1},
{"Nagpur",2,arr+2},
{"Kanpur",3,arr}
};
struct place *p=a;
int i;
for(i=0;i<=2;i++) { printf("%d",(2+a[i].i)); } } a . Error b . aipuragpuranpur c . ipurgpurnpur d . purpurpur Q. 3 . Find the correct output void main() { int var,x=1,y=2; switch(var) { case x: x++; case y: y++; } printf("%d %d",x,y); } a . 1 3 b . 2 2 c . No output d . None of these Q. 4 . Find the output. void main() { char c[]="lak\\bshya"; printf("%s",c); } a . lashya b . lak\shya c . lak\bshya d . lakshya Q. 5 . File opening is a . a action of connecting a program to a file b . a action of connecting a program to a buffer c . a default action of file processing d . None of these Q. 6 . Find out the output. int funcall(); void main() { int z; z=funcall(); printf("%d",z); } int funcall() { auto int arr[]={15,2,3,4,5,6},x=5; return x=arr[0]; x=arr[1]; printf("%d",x); } a . 15 b . 2 c . Error d . Garbage output Q. 7 . Find the output void main() { if(printf("Hello")); else printf("Hai"); } a . Hello b . Hai c . Compilation error d . Statement missing Q. 8 . The value with in [ ] in an array declaration specifies a . Largest permitted subscript value b . Size of the array c . Both a and b d . None of these Q. 9 . Find the output. void main() { int x=0xFFFB; printf("%d",x); } a . 5 b . -5 c . 65631 d . 32762 Q. 10 . Find out the output. void main() { int a=1,b=2,c=3,d=4; printf(" %d %d",a,b); printf(" %d %d",c,d); } a . Run time Error b . Compile time Error c . 1 2 3 4 d . None of these Q. 11 . Find out the true statement. a . A union variable can be assigned to another union variable. b . The address of union variable can be extracted by using & operator. c . A function can return a pointer to the union. d . All the above Q. 12 . Find the correct output void main() { int x=11,y=5,z=2; x%=y*=z; printf("%d",x); } a . 2 b . 1 c . 25 d . 27 Q. 13 . Find the output void main() { int i=-3,j=2,k=0,m; m=++i && j++ && ++k; printf("\n%d, %d, %d, %d",i,j,k,m); } a . -2,-3, 1,1 b . -3, 2, 0,1 c . -2, 3, 0,1 d . -2, 3, 1,1 Q. 14 . Find out the output #include"stdio.h" void main() { int (*p)(const char* , ...); p=printf; p("hello","%c",'CB'); } a . helloC b . helloCB c . hello%c d . hello Q. 15 . Find the correct output void main() { unsigned i=1; signed j=-1; if(ij)
printf("greater");
else
if(i==j)
printf("equal");
}
a . less
b . greater
c . equal
d . None of these
Q. 16 . Find the correct output
#define CAL(X) X+1
void main()
{
int a=3;
int b=4*CAL(a*4);
printf("%d",b);
}
a . Garbage value
b . 52
c . 64
d . 49
Q. 17 . Self referential structure
a . Used to create a memory link.
b . Plays an important role in linked list creation.
c . Contains the object of same structure which is of pointer type.
d . All the above
Q. 18 . Find the correct output
void main()
{
int *p,i=10;
void *q;
p=&i;
q=p;
printf("%d",*q++);
}
a . 10
b . 11
c . Error
d . None of these
Q. 19 . Find the output
struct xx
{
char y;
int x;
};
void main()
{
struct xx s={‘a’,15};
switch(s)
{
case ‘a’:
printf("Allowed");
break;
case 15:
printf("Not allowed");
break;
default:
printf("No");
}
}
a . Allowed
b . Not allowed
c . No
d . None of these
Q. 20 . Find the output.
void main()
{
int i;
for(i=-9;!i;i++);
printf("%d",-i);
}
a . 8
b . 9
c . 0
d . 1
Q. 21 . Find out the output.
void main()
{
int arr[5]={},i;
char *p;
for(i=0;i<5;i++) p="(char*)arr;" m="hii(m="1,n="2);" k="!m?n:!n?m:m<="n?m:n;" i="j="l="0;" s="1;">=n))&&(l+=n,s=-s,++j>=m))
break;
i-=s;
l+=s*m;
k=l>0?l1.5)
printf("fool");
else
printf("stupid");
}
a . fool
b . stupid
c . garbage value
d . None of these
Q. 12 . Find the correct output
void main()
{
int i=5,j=3;
printf("%d",show(i,j));
}
show(int a,int b)
{
a=a*5;
b*=b;
return(!a+ --b);
}
a . Error
b . 0
c . 8
d . 2
Q. 13 . Find out the output
#include"limits.h"
void main()
{
int a[INT_MAX];
printf("%d",sizeof(a));
}
a . 32767
b . 63534
c . -2
d . 2
Q. 14 . Find the correct output
void main()
{
int a;
char b;
float c;
printf("%d",sizeof(a+sizeof(b+c));
}
a . 2
b . 1
c . 4
d . Error
Q. 15 . Find out the output
int i;
int increment( int i )
{
i++;
return i;
}
int main()
{
for( i = 0; i < i="increment(" i="%d\n" i="9" i="10" i="11" p="CITE" q="CITE" p="="q)" a="5,b="7;" p="&a;" p="10;" a="4,b="5,c;">b?c=a:c=b);
}
a . 4
b . 5
c . Error, lvalue required
d . None of these
Q. 22 . Find the output.
void main()
{
int *p, a[5]={1, 2, 3, 4, 5};
p=&a;
printf("%d %d %d",*p,++*p,++*p);
}
a . 1 2 3
b . 3 2 1
c . 3 3 2
d . None of these
Q. 23 . A union can be a member of
a . Structure
b . Array
c . Both a and b
d . None of these
Q. 24 . Find the correct statement
a . int a=10;
int arr[a];
b . int a,b,c;
int *p={&a,&b,&c};
c . static int a,b,c;
int *q={&a,&b};
d . int a=1,b=2,c=3;
int arr[]={a,b,c};
Q. 25 . Find out the output
void main()
{
int a=10;
a=call(a=call(~a));
printf("%d",a);
}
call(int a)
{
return a;
}
a . 10
b . -11
c . 0
d . None of these
Q. 26 . Find the correct output
#define FLOAT(x) 3.##x
void main()
{
printf("%f",FLOAT(14));
}
a . 3.14
b . 3.140000
c . 3.000000
d . None of these
Q. 27 . State the correct statement.
a . Nested union is not possible.
b . Self referential union is possible
c . Different interpretations for the same memory location are possible in structure.
d . Both a and c
Q. 28 . Find out the output
void main()
{
int a=256;
char *p=&a;
*++p=2;
printf("%d",a);
}
a . 512
b . 258
c . Error
d . None of these
Q. 29 . Find the correct output
void main()
{
static int i=i++,j=j++;
printf("%d%d",i,j);
}
a . 11
b . Garbage value
c . Error
d . None of these
Q. 30 . The keywords in ‘r’ family are
a . register, real
b . register, return, repeat
c . register, return
d . none of these
MCQ of c programming 19

Q. 1 . Find out the output
void main()
{
int i,j,a[6],b[3];
j=a[i=0]=1;
printf("%d","lakshya"[(sizeof(a[i],"lakshya"[sizeof b[j]]))]);
}
a . 2
b . 97
c . 117
d . 118
Q. 2 . Find the output.
void main()
{
int x=3;
float y=1;
while(x! =y)
{
x--;
y++;
if(x==y)
printf("%d %d",x,y);
}
a . 2 0
b . 2 suffering
c . 2 2
d . Error
Q. 3 . An I/O stream is
a . a text stream
b . a binary stream
c . Both a and b
d . None of these
Q. 4 . Find the correct output
void main()
{
int i=5;
i=i++ - --i + ++i;
printf("%d",i);
}
a . 5
b . 7
c . 8
d . None of these
Q. 5 . Find the output.
extern int x;
void main()
{
typedef int myint;
myint x;
printf ("%d", x) ;
}
a . 0
b . Garbage
c . Error, multiple declaration for x
d . None of these
Q. 6 . Find the output
void main()
{
int i=1;
for(i;i++<=3;) { switch(i) { case 1: printf("one"); continue; case 2: printf("two"); break; case 3: printf("three"); continue; } } } a . onetwothree b . twothree c . Error, misplaced continue d . No output Q. 7 . Find the correct output? void main() { int n=2,i; float s=0.0; for(i=1;i<=n;i++) s=s+(float)1/(i*i); } a . 1.000000 b . 1 c . 1.500000 d . 1.250000 Q. 8 . Find the o/p struct date { int day,month,year; } void main() { struct date today={3,7,6,2007}; printf("%d %d %d",today.day,today.month,today.year); } a . 3 7 6 b . 7 6 2007 c . Compilation error d . None of these Q. 9 . Find out the output void main() { char *p="rama"; char *q=0; char *r="\bsita"; strcpy(q,p); strcat(q,r); printf("%s",q); } a . ramsita b . ramasita c . rama\sita d . None of these Q. 10 . Find out the output void main() { int x=32768; if(2*x) printf("HaHa"); else printf("HoHo"); } a . HaHa b . HoHo c . Expression syntax error d . None of these Q. 11 . Find the output. void main() { int x=5; void *p; p=&x; printf("%d",*(int *)p); } a . 5 b . Garbage c . Generic pointer can not be dereferenced d . No output Q. 12 . Find out the output int x=5; void modify(int); void main() { printf("%d\t",x); { x=10; modify(x); printf("%d",x); } printf("%d",x); } void modify(x) { x=15; x++; } a . 5 10 10 b . 5 16 16 c . Expression syntax error d . None of these Q. 13 . A set of names can be represented as a a . Two dimensional array of characters b . One dimensional array of strings c . One dimensional array of pointers to character d . All of the above Q. 14 . A character constant is a . 1 byte long b . 2 bytes long c . system dependent d . none of these Q. 15 . Predict output if value 10 is given as input. main() { int i; printf("%d",scanf("%d",&i)); } a . 1 b . 10 c . Garbage d . None of these Q. 16 . Find the output. void main() { int i=10,*p; p=&i; printf ("%d %d",*(p++), (*p)++); } a . 11 10 b . 0 10 c . 10 11 d . Garbage garbage Q. 17 . Find the output union usa { unsigned int x[2]; char ch[4]; }canada; void main() { strcpy(canada.ch,"xyz"); printf("%s %d",canada.ch,canada.x[1]); } a . Error: Library function not allowed initializing union member. b . xyz 120 c . xyz 121 d . xyz 122 Q. 18 . Find out the output void main() { char a[10]="lakshya"; int i=0,j=0; while(i<=strlen(a)) { i=j++; if(a[i]==’a’a[i]==’e’a[i]==’i’a[i]==’o’a[i]==’u’) { while(iy? x:y
void main()
{
int a,b;
a=MAX(1,2)+3;
b=MAX(4,3)+5;
printf("%d %d",a,b);
}
a . 5 4
b . 5 9
c . 5 8
d . None of these
Q. 20 . Find the output.
static int i;
void main()
{
for(;~i;i--)
printf("%d",i);
}
a . 0 -1 -2 -3…….
b . 0
c . 0 -1 0 -1……
d . None of these
Q. 21 . Find the correct output
void main()
{
char a[4]="rama";
char b[]="shyama";
printf("%d %d", sizeof(a),sizeof( b)) ;
}
a . 4 7
b . 5 6
c . 5 7
d . 4 6
Q. 22 . The keywords in ‘r’ family are
a . register, real
b . register, return, repeat
c . register, return
d . none of these
Q. 23 . Find out the output
struct xx
{
int xx;
char yy[10];
};
struct yy
{
char xx[10];
int yy;
};
struct xx *rec;
struct yy rect={"hari",20};
void main()
{
rec=(struct xx*)▭
printf("%c %s",rec->xx,rec->yy);
}
a . hari
b . h ri
c . riha
d . r ha
Q. 24 . Find out the output
void main()
{
char *p;
printf("%d %d ",sizeof(*p+++2),sizeof(p+++4));
}
a . 1 2
b . 2 2
c . Error
d . 1 1
Q. 25 . Find the correct output
void main()
{
int i;
float f=3.14;
float compute(float);
i=compute(f);
printf("%d",i);
}
float compute(float x)
{
if(x==3.14)
return(0);
else
return(1);
}
a . Suffering
b . Garbage
c . 0
d . 1
Q. 26 . Find the correct output
void main()
{
int i,j=6;
for(;i=j;j-=2)
printf("%d",j);
}
a . Error
b . Garbage values
c . 642
d . 6420
Q. 27 . Find the output
void main()
{
char a[5]={‘c’,’i’,’t’,’e’, 0};
printf ("%s",a[4]);
}
a . 0
b . Null
c . Error
d . None of these
Q. 28 . Octal numbers are used
a . in computer hardware
b . when binary numbers are too long
c . external to the computer
d . in preference to 'hex' numbers
Q. 29 . Find the output.
void main()
{
struct nm;
{
int roll[5];
char name[10];
};
printf("%d",sizeof(nm));
}
a . 20
b . 21
c . 10
d . None of these
Q. 30 . Find the output
void main()
{
int i=4,j=-3;
mul(&i,j);
printf("%d %d",i,j);
}
mul(int *a,int b)
{
a=*a**a;
b=b*b;
}
a . 4 3
b . 4 9
c . 16 -3
d . 16 9
MCQ of c programming 20


Q. 1 . Find out the output
void main()
{
int i=0,c=0;
for(i;i<10;i--) emp="{278," p="&emp;">eid II. p.eid III. (*p).eid IV. (*p)->eid
a . Only I
b . Only III
c . Both I & III
d . All of the above
Q. 4 . Arrange the operators ~,= =, &&, *, ^ in the increasing order of precedence.
a . = =, ^ , * , && , ~
b . && , ^ , = = , * ,~
c . * , = = , && , ^ , ~
d . && , = = , ^ , * ,~
Q. 5 . Which one of the following is/are wrong?
int a,b[5],c[3];
I. a=b[2];
II. b[3]=a;
III. b[1]=c[2];
IV. c[0]=b[2
a . only II
b . II & III
c . III & IV
d . only I
Q. 6 . Find the correct output
void main()
{
int a=1,b=2,c=3,d=4;
printf("%d",!a?b?!c:!d:a);
}
a . 1
b . 2
c . 3
d . 4
Q. 7 . Find the correct output
void main()
{
int a=5,b=6,c=2,d;
d=(a++,++b,c++);
printf("%d%d%d",d,a,c);
}
a . 263
b . 252
c . 162
d . 253
Q. 8 . Find the output.
void main()
{
unsigned int i=5;
while(i-->=0)
printf("%d",i);
}
a . 12345
b . lvalue required
c . infinite loop
d . None of these
Q. 9 . Which of the following function is appropriate to read one character at a time?
a . fscanf()
b . fgetc()
c . read()
d . fgets()
Q. 10 . Find the output
static int i=5;
void main()
{
int i=10;
call(i/5);
printf("%d",i);
}
call(int i)
{
return i/2;
}
a . 1
b . 10
c . 5
d . None of these
Q. 11 . Find out the output
void main()
{
char *p;
printf("%d %d ",sizeof(*p+++2),sizeof(p+++4));
}
a . 1 2
b . 2 2
c . Error
d . 1 1
Q. 12 . Find out the output
void main()
{
show(5);
}
show(int x)
{
static int i=1;
while(i++<5) x="65536+1;" p="0X0000;" p="10;" arr2d="="*" arr2d ="="" x="55"> are known as
a . Data access operators
b . Structure access operators
c . Member access operators
d . None of these
Q. 26 . Find the output
void main()
{
FILE *p;
printf("%d %d",stderr->fd,_streams[3].fd);
}
a . 2 3
b . 4 4
c . 1 2
d . Error
Q. 27 . Find the output
void main()
{
printf("%d",wow(5));
}
wow(int x)
{
if(x<=0) return 1; else return (wow(x-1)+x); } a . 15 b . 16 c . 11 d . 12 Q. 28 . Static global variable have a . Internal linkage b . External linkage c . No linkage d . None of these Q. 29 . Find out the output void main() int c; { int a=5,b=10; c=a+=b-=a; printf("%d %d %d",a,b,c); } a . Compile time error b . 5 10 5 c . 10 5 10 d . 10 10 5 Q. 30 . Which of the following is/are true for nested if I. It can only test for equality. II. Conditions may be repeated for number of times. III. It can evaluate relational or logical expressions. IV. Character constants are automatically converted to integers. a . All of the above b . I & II c . I, II & III d . II, III & IV MCQ of c programming 21 Q. 1 . Find the correct output #define SWAP(type,i,j) {type t=i;i=j;j=t;} void main() { int s=5,t=2; SWAP(int,s,t); printf("%d %d",s,t); } a . 5 2 b . 2 5 c . 5 5 d . None Q. 2 . Find the correct output #define min(x,y) x=(xb)
a=a-b;
else
b=b-a;
}
printf("%d",a);
}
a . 3
b . 6
c . 18
d . None of these
Q. 12 . Unary operators are
a . Operator dependant
b . Position dependant
c . Value dependant
d . Both b and c.
Q. 13 . what is the o/p in turbo compiler?
struct stud
{
int x:18;
char *y;
f loat z;
}s1;
void main()
{
printf("%d",sizeof(s1));
}
a . 7
b . 1
c . 8
d . Error
Q. 14 . Find the correct output
void main()
{
int a[]={6,7,8,9},i;
compute(a);
for(i=3;i>=0;i--)
printf("%d",a[i]);
}
compute(int *p)
{
int i;
for(i=0;i<4;i++) p="*p-1;" ptr =" (int*)(&a+1);" i="1;" x="10,y="5,p,q;" p="x">9;
q=p(x=5,y=10);
printf("%d %d %d",q,x,y);
}
a . 1 10 5
b . Error
c . 1 5 10
d . 0 10 5
Q. 23 . State the true statement.
‘void ‘ is an empty data type associated with
a . all aggregate types
b . all data types
c . all functions and pointers
d . all the above
Q. 24 . The area or scope of the variable depends on its
a . Date type
b . Storage class
c . System type
d . None of these
Q. 25 . Aspect ratio of a monitor is
a . height and width ratio
b . number of pixels per inch
c . diagonal length of monitor
d . none of these
Q. 26 . Find the correct output
#define div(x) x/x
void main()
{
printf("%d",div(16)*16);
}
a . 1
b . 16
c . 256
d . None of these
Q. 27 . Find the output if inout is 5 6?
void main()
{
int x,y;
scanf("%d",&x);
scanf("%c %d",&y);
printf("%d %d",x,y);
}
a . 5 6
b . 5 7
c . 5 garbage
d . garbage garbage
Q. 28 . Find the output
void main()
{
int x[][3]={1,2,3,4,
4,5,6};
int i;
for(i=0;i<3;i++) a="5;" a="find(a+="find(a++));">
int i;
void increment( int i )
{
i++;
}
int main()
{
for( i = 0; i < i="%d\n" i="9" i="10" i="11" p="0X0000FFFF;" x="5;" p="&x;" i="98;" a="5,b="6,c="2,d;" d="(a++,++b,c++);" a="10;" p="{&a,&b,&c};" q="{&a,&b};" a="1,b="2,c="3;" x="4;" i="0;i<4;i++)" x="-17">>2;
printf ("%d", x);
}
a . -3
b . 3
c . -5
d . 7
Q. 18 . Find the correct output
void main()
{
int *p,*q="hello";
*p=*q;
printf("%s",p);
}
a . Error, suspicious pointer conversion
b . he
c . hello
d . None of these
Q. 19 . Find out the output.
void main()
{
int i=98;
while(100-i++)
printf("%u",i);
switch(i)
case ‘e’:
printf("Fool");
}
a . 98 99 100
b . 99 100
c . 99 100 Fool
d . Expression syntax error
Q. 20 . Find the output.
#include"stdio.h"
void main()
{
FILE *p;
char ch;
p=fopen("raja.txt","w");
putc(50,p);
putc(80,p);
putc(70,p);
while((ch=getc(p))!=EOF)
putch(ch);
fclose(p);
}
a . 508070
b . 2PF
c . 50PF
d . None of these
Q. 21 . The main advantage of union over structure is
a . Memory mapping
b . Memory utilization
c . Memory optimization
d . Memory leak
Q. 22 . ‘for’ loop can’t be written using do-while loop if
a . Start value is not given
b . Stop value is false
c . Step value is not given
d . Stop value is true
Q. 23 . Which of the following is false regarding bit fields?
a . Bit fields may share a storage unit with other structure members.
b . Bit fields must entirely reside in a storage unit its appropriate type.
c . Bit fields only applicable to unsigned integral but not signed integral.
d . Bit fields are used to construct the protocol header fields.
Q. 24 . Macros like INT_MIN, INT_MAX are defined in which header file.
a . stdio.h
b . limits.h
c . dos.h
d . none of these
Q. 25 . Find the correct output
void main()
{
int i=5;
i=i++ + ++i + i++;
printf("%d",i);
}
a . 18
b . 20
c . 24
d . None of these
Q. 26 . Find the output
void main()
{
printf("%f",9/5);
}
a . 1.0
b . 1.8
c . 2.0
d . None of these
Q. 27 . Find the output.
void main()
{
struct nm;
{
int roll[5];
char name[10];
};
printf("%d",sizeof(nm));
}
a . 20
b . 21
c . 10
d . None of these
Q. 28 . Which of the following is a 8 bit binary coding?
a . BCD
b . ASCII
c . EBCDIC
d . none of these
Q. 29 . Find out the output.
void main()
{
printf("%d",-65535);
}
a . -65535
b . 0
c . 1
d . -1
Q. 30 . Find out the output
void main()
{
int a="%d";
printf("%d",a);
}
a . %d
b . 25637
c . 37
d . %


VISIT HERE

What is pointer ?
memory model
near pointer
Physical address calculation
huge pointer

5 comments:

  1. Sir , where i get Answers to C language MCQ's

    ReplyDelete
  2. hi Vibhore
    I will publish soon

    ReplyDelete
  3. sir could you plz provide the solutions quickly.....plz

    ReplyDelete
  4. Please,give the answers of these questions.

    ReplyDelete
  5. I want a definition of keywords I search goggle I cant get answer succesfully

    ReplyDelete