main()
{
int i = -3,j=2,k=0,m;
m= ++i || ++j && ++k;
printf("%d%d%d",i,j,k,m);
}

Answers were Sorted based on User's Feedback



main() { int i = -3,j=2,k=0,m; m= ++i || ++j && ++k; printf("%d%d%d",i,j,k,m);..

Answer / harend

results :

i=-2
j=2
k=0
m=1
First, the '&&' part is to be considered over '||'.

AS follow: m = ++i||++j&&++k (is given)
what ever be the result of (++j&&++k),the value of m =1
,since the new value i= -2 (i.e a non zero value so taken as
true or 1)
so,
1||(++j&&++k) will always be true, that is 1 . compiler
ignores ++j ,++k and only consider ++i.

thank you !

Is This Answer Correct ?    24 Yes 6 No

main() { int i = -3,j=2,k=0,m; m= ++i || ++j && ++k; printf("%d%d%d",i,j,k,m);..

Answer / ep

After the execution of the m evaluation the variables can be:

i = -2
j = 2
k = 0
m = 1

All of of this is because compilers do NOT completely
evalute expressions if they can short cut the evaluation.

Anyway, this is very bad programming.

Is This Answer Correct ?    18 Yes 10 No

main() { int i = -3,j=2,k=0,m; m= ++i || ++j && ++k; printf("%d%d%d",i,j,k,m);..

Answer / mayur dharmik

printf("%d%d%d",i,j,k,m);

it has only 3 %d.
So, it will print only 3 value.

Is This Answer Correct ?    9 Yes 2 No

main() { int i = -3,j=2,k=0,m; m= ++i || ++j && ++k; printf("%d%d%d",i,j,k,m);..

Answer / mayur dharmik

output
-220

i.e,
i=-2, j=2, k=0.
it will print only 1st three value.

Is This Answer Correct ?    5 Yes 2 No

main() { int i = -3,j=2,k=0,m; m= ++i || ++j && ++k; printf("%d%d%d",i,j,k,m);..

Answer / tarkibitact

-2301

Is This Answer Correct ?    1 Yes 0 No

main() { int i = -3,j=2,k=0,m; m= ++i || ++j && ++k; printf("%d%d%d",i,j,k,m);..

Answer / jeke kumar gochhayat

i=-2
j=3
k=1
m=1

Is This Answer Correct ?    11 Yes 12 No

main() { int i = -3,j=2,k=0,m; m= ++i || ++j && ++k; printf("%d%d%d",i,j,k,m);..

Answer / nidhi yadav

here logical && has higher priority than ||. so the block
(++j&&++k)will execute first and ans of this will be (3&&1=0)
since value increment first due to preincrement operator. now
the block(++i||0)will execute as (-2||0=1) since || opertor always gives true value except(0||0=0).
thus ans will be i=-2,j=3,k=1,m=1

Is This Answer Correct ?    2 Yes 7 No

Post New Answer

More C Interview Questions

Why the use of alloca() is discouraged?

2 Answers   Oracle,


What does d mean?

0 Answers  


define switch statement?

6 Answers   CTS,


52.write a “Hello World” program in “c” without using a semicolon? 53.Give a method to count the number of ones in a 32 bit number? 54.write a program that print itself even if the source file is deleted? 55.Given an unsigned integer, find if the number is power of 2?

9 Answers  


WAP to convert text into its ASCII Code and also write a function to decode the text given?

2 Answers  






while loop contains parts a) initialisation, evalution of an expression,increment /decrement b) initialisation, increment/decrement c) condition evalution d) none of the above

0 Answers  


What is %g in c?

0 Answers  


Why c is called procedure oriented language?

0 Answers  


what will be maximum number of comparisons when number of elements are given?

0 Answers  


how to convert binary to decimal and decimal to binary in C lanaguage

7 Answers   BPO, Far East Promotions, IBM, RBS,


What is const keyword in c?

0 Answers  


#include<stdio.h> main() { int a[3]; int *I; a[0]=100;a[1]=200;a[2]=300; I=a; Printf(“%d\n”, ++*I); Printf(“%d\n”, *++I); Printf(“%d\n”, (*I)--); Printf(“%d\n”, *I); } what is the o/p a. 101,200,200,199 b. 200,201,201,100 c. 101,200,199,199 d. 200,300

4 Answers   Tieto,


Categories