Welcome Guest | Sign in | Register

Home > C Programming > Operators > Questions and Answers

01. What will be printed as the result of the operation below?
main()
{
int x=20,y=35;
x=y++ + x++;
y= ++y + ++x;
printf("%d%d",x,y);
}   
A. 5 8 9 4 B. 5 7 9 4
C. 5 8 9 5 D. 5 7 8 4

Answer and Explanation

Answer: 5 7 9 4

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
02. What will be printed as the result of the operation below?
main()
{
int x=5;
printf("%d,%d,%d",x,x<<2,x>>2);
}
A. 5,21,1 B. 5,20,1
C. 5,19,0 D. 5,19,1

Answer and Explanation

Answer: 5,20,1

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
03.  Given the following program fragment, which one of the given option is correct?
main ()
{
int i, j, k;
i = 3;
j =2*(i++);
k =2*(++i);
}
A. j = 6, k = 10. B. i = 5, k = 6.
C. j = 6, k = 8. D. i = 4, j = 6.

Answer and Explanation

Answer: j = 6, k = 10.

Explanation:
In the expression j = 2 * (i++) the value of i is used before incrementing and in expression k =2*(++i); will get incremented first and then used in the expression

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
04. Suppose a,b,c are integer variables with values 5,6,7 respectively.What is the value of the expression:
!((b+c)>(a+10))
A. 1 B. 6
C. 15 D. 0

Answer and Explanation

Answer: 1

Explanation:
1.!((b+c)>(a+10))
2. !((6 + 7) > (5+10))
3. !(13 > 15) 13 is less than 15 so it will return False (0 ).
4. !(0). Not of 0 is 1.

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
05. What value of c will get printed?
main()
{
int a,b,c;
a=10;
b=20;
c=printf("%d",a+ ++b);
printf("\n%d",c);
}   
A. 23 B. 22
C. 30 D. Compilation Error

Answer and Explanation

Answer: 22

Explanation:
printf() will return no. of bytes it printed Expression becomes
c = 2 + ++b;
then value of b is incremented before addition

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
06. What the below statement will print if a=10?
printf("%d %d",a, !a++); 
A. 11 0 B. 10 10
C. 10 0 D. 0 10

Answer and Explanation

Answer: 11 0

Explanation:
Values in the function get passed from right to left. First !a++ get processed which pass zero as argument and make a equal to 11

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
07. What will be the output?
main()
{
int i;
i = 10;
printf("%d\t",5,6);
printf("%d", i , i++);
}  
A. 5 11 B. 6 10
C. 6 11 D. 5 10

Answer and Explanation

Answer: 5 11

Explanation:
Value in a function get passed from right to left. First i++ get passed and it make i = 11.

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
08. What the below statement will print if a=10 and b = 20?
printf("%d",a==b); 
A. 20 B. 10
C. 1 D. 0

Answer and Explanation

Answer: 0

Explanation:
a==b is a expression and will return 1 (true) or 0 (False) depending on the values of a and b. Here a and b are not equal so 0 is printed.  

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
09. What will be printed as the result of the operation below?
main()
{
int x=10, y=15;
x = x++;
y = ++y;
printf("%d %d",x,y);
}  
A. 10, 16 B. 11, 16
C. 10, 16 D. 11, 15

Answer and Explanation

Answer: 11, 16

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
10. What is the output of the following program?
void main(){
printf("2+3=%d",2+3);
}  
A. 2+3=0 B. 2+3=2+3
C. 2+3=5 D. 5=2+3

Answer and Explanation

Answer: 2+3=5

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum



Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.