Control
Instructions (C-FAQ's)
Q1: What is the output for the program given below?
#include<stdio.h>
int main()
{
int
x=0, y=10, z=20;
*(
(x) ? &y: &z) = x ? y : z ;
printf("
%d %d %d\n ", x, y, z );
return
0;
}
Output:
0 10 20
Q2: Predict the output for the following code ?
#include<stdio.h>
int main()
{
int a=2, b=5;
if(
a%2 = b%5 )
printf("Hello World\n");
return 0;
}
A. Error: " Invalid Rvalue assignment "
B. Error: "Expression Syntax"
C. Error: "Invalid Lvalue assignment"
D. Hello World
Output:
C. Error:
"Invalid lvalue assignment"
Q3: What is the output of the following code?
#include<stdio.h>
int main()
{
int
i = 5;
float
j = 5.0 ;
if
( i == j )
printf(" Equal \n");
else
printf("Not
Equal \n");
return
0;
}
Output:
Equal
Q4: What is the output of the following code?
int main()
{
int
x=0, y=5;
y
== 5 ? x=10 : x=20 ;
if(
x )
{
printf("%d
", x );
}
return
0;
}
A. 10
B. 20
C. No output
D. Invalid lvalue is assignment
Output:
D. Invalid
lvalue is assignment
No comments:
Post a Comment