1. What are the outputs?
main()
{
int i;
printf("%d", &i)+1;
scanf("%d", i)-1;
}
a. Runtime error.
b. Runtime error. Access violation.
c. Compile error. Illegal syntax
d. None of the above
{
int i;
printf("%d", &i)+1;
scanf("%d", i)-1;
}
a. Runtime error.
b. Runtime error. Access violation.
c. Compile error. Illegal syntax
d. None of the above
Ans : d
printf( ) prints address/garbage of i,
scanf() dont have & sign, so scans address for i
+1, -1 dont hav any effect on code
scanf() dont have & sign, so scans address for i
+1, -1 dont hav any effect on code
………………………………………………….
2. What are the outputs?
#include<stdio.h>
#define SQR(x) x * x
main()
{
printf("%d", 225/SQR(15));
}
a. 1
b. 225
c. 15
d. none of the above
b. 225
c. 15
d. none of the above
Ans : b
……………………………………………………..
3. What are the outputs?
#include<stdio.h>
main()
{
int i, j;
scanf("%d %d"+scanf("%d %d", &i, &j));
printf("%d %d", i, j);
}
a. Runtime error.
b. 0, 0
c. Compile error
d. the first two values entered by the user
Ans: d) two values entered, 3rd will be null pointer assignment
b. 0, 0
c. Compile error
d. the first two values entered by the user
Ans: d) two values entered, 3rd will be null pointer assignment
4. What are the outputs?
#include<stdio.h>
main()
{
printf("%d,
%d", sizeof('c'), sizeof(100));
}
a. 1, 2
b. 2, 100
c. 4, 100
d. 4, 4
b. 2, 100
c. 4, 100
d. 4, 4
Ans : 1, 2
……………………………………………………
5. What are the outputs?
#include<stdio.h>
main()
{
int i = 100;
printf("%d", sizeof(sizeof(i)));
}
a. 2
b. 100
c. 4
d. none of the above
b. 100
c. 4
d. none of the above
Ans a
…………………………………………………….
6. What are the outputs?
#include<stdio.h>
void main ()
{
int x = 10;
printf ("x =
%d, y = %d", x--,x++);
}
a. 10, 10
b. 10, 9
c. 10, 11
d. none of the above
b. 10, 9
c. 10, 11
d. none of the above
Output: x=11, y=10
…………………………………………………….
7. What are the outputs?
#include<stdio.h>
main()
{
int i =10,
j = 20;
printf("%d,
%d, ", j-- , --i);
printf("%d,
%d ", j++ , ++i);
}
a. 20, 10, 20, 10
b. 20, 9, 20, 10
c. 20, 9, 19, 10
d. 19, 9, 20, 10
b. 20, 9, 20, 10
c. 20, 9, 19, 10
d. 19, 9, 20, 10
Ans C
8. What are the outputs?
#include<stdio.h>
main()
{ if ((1||0)
&& (0||1))
{
printf("OK I am done.");
}
else
{
printf("OK I am gone.");
}
}
a. OK I am done
b. OK I am gone
c. compile error
d. none of the above
b. OK I am gone
c. compile error
d. none of the above
Ans a
…………………………………………………
9. What are the outputs?
#include<stdio.h>
void main(){
int j=320;
char
*p=(char *)&j;
printf("%d",*p);
}
Ans 64
…………………………………………………..
10 What are the outputs?
#include<stdio.h>
#define x 5+2
void main(){
int i;
i=x*x*x;
printf("%d",i);
}
Ans 27
(i=5+2*5+2*5+2
=5+10+10+2
=27
)
…………………………………………………..
11. What are the outputs?
#include<stdio.h>
void main()
{
char c=125;
c=c+10;
printf("%d",c);
}
Ans –121
(Char value range +127 to –128, print in cycle order. 125+1= 126,125+2=
127,125+3=-128,125+4=-127,125+5=-126,125+6=-125,125+7=-124,125+8=-123,
125+9=-122,125+10=-121)
12. What are the outputs?
#include<stdio.h>
void main(){
float i=4.5;
if(i==4.5)
printf("Equal to(==)");
else if(i<4.5)
printf("Less than(<)");
else
printf("Greater than(>)");
}
Ans: Equal to(==)
…………………………………………………
13.What are the outputs?
#include<stdio.h>
void main(){
int i=4,x;
x=++i + ++i + ++i;
printf("%d",x);
}
Ans 21(x=++i + ++i + ++i= 7 +7+7)
…………………………………………………..
14. What are the outputs?
#include<stdio.h>
void main(){
int x;
for(x=1;x<=5;x++);
printf("%d",x);
}
Ans: 6
……………………………………………………..
15. What are the outputs?
#include<stdio.h>
main()
{
float me = 1.1;
double you = 1.1;
if(me==you)
printf("I love you");
else
printf("I hate
you");
}
Ans : I hate you
…………………………………………………….
16. What are the outputs?
#include<stdio.h>
#define clrscr() 100
main()
{
clrscr();
printf("%d\n",clrscr());
}
Ans: 100
No comments:
Post a Comment