Professional Documents
Culture Documents
#inlcude <stdio.h>
int main()
{
int i = 0;
if ( i = 0 )
{
printf(Hello, World);
}
else
{
printf(How are you?);
}
return 0;
}
A) Hello, World
B) How are you?
C) No Output
D) Syntax Error
11. What will be output if you will compile and execute the
following c code?
#define x 5+2
void main(){
int i;
i=x*x*x;
printf("%d",i);
}
A)
B)
C)
D)
E)
343
27
133
Compiler error
None of above
12. What will be output if you will compile and execute the
following c code?
void main(){
char c=125;
c=c+10;
printf("%d",c);
}
A)
B)
C)
D)
E)
135
+INF
-121
-8
Compiler error
13. What will be output if you will compile and execute the
following c code?
void main(){
int a=2;
if(a==2){
a=~a+2<<1;
printf("%d",a);
}
else{
break;
}
}
A)
B)
C)
D)
E)
14. What will be output if you will compile and execute the
following c code?
void main(){
int a=10;
printf("%d %d %d",a,a++,++a);
}
A)
B)
C)
12 11 11
12 10 10
11 11 12
D)
E)
10 10 12
Compiler error
15.
#include "stdio.h"
#include "string.h"
void main(){
int i=0;
for(;i<=2;)
printf(" %d",++i);
}
A)
B)
C)
D)
E)
012
0123
123
Compiler error
Infinite loop
16.
What will be output if you will compile and execute the following
c code?
void main(){
int x;
for(x=1;x<=5;x++);
printf("%d",x);
}
A)
B)
C)
4
5
6
D)
E)
Compiler error
None of above
17. What will be output if you will compile and execute the
following c code?
int * call();
void main(){
int *ptr;
ptr=call();
clrscr();
printf("%d",*ptr);
}
int * call(){
int a=25;
a++;
return &a;
}
A)
B)
C)
D)
E)
25
26
Any address
Garbage value
Compiler error
18.
#define max 5;
void main(){
int i=0;
i=max++;
printf("%d",i++);
}
A)
B)
C)
D)
E)
5
6
7
0
Compiler error
19.
#include <stdio.h>
main()
{
char *p = 0;
*p = 'a';
printf("value in pointer p is %c\n", *p);
}
a) It will print a
b) It will print 0
c) Compile time error
d) Run time error
20.
#include <stdio.h>
int main()
{
int c = 2 ^ 3;
printf("%d\n", c);
}
a) 1
b) 8
c) 9
d) 0