void main()
{
int i=1;
printf("%d%d%d",i,++i,i++);
}
Cau u say the output....?

Answers were Sorted based on User's Feedback



void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?..

Answer / shanthi

122

Is This Answer Correct ?    2 Yes 3 No

void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?..

Answer / subash

221
because it starts executing from right to left
so it first executes i++(the increment will happen when
entire printf statement is executed so now ++i which means
it is the pre incremant so now i becomes 2

Is This Answer Correct ?    2 Yes 3 No

void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?..

Answer / kiran

The output will be 1 2 2...
First the assigned value of i(1) is printed. Then (++i) prints the Incremented value of i which is 2 will be printed.
Now as the Postfix operator only prints thhe value first and then increments...so the value of i is again 2..

Is This Answer Correct ?    4 Yes 5 No

void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?..

Answer / we r the new inventors

the explanation above are also correct but think they are somewhat wrong because it was post increment of i.so value of i will become 2..

Is This Answer Correct ?    1 Yes 2 No

void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?..

Answer / we are the new inventors

above answers are also right but i think they are somewhat wrong..because its a post increment of i so ans will become 2...

Is This Answer Correct ?    0 Yes 1 No

void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?..

Answer / sums

The ans is obv 3 3 1...
The explanations given are also correct
For all those u r giving other answers without even giving the reason should at least run the program in "gcc" before writing anything

Is This Answer Correct ?    2 Yes 4 No

void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?..

Answer / sam

first the initial value of i is 1
i++ is post decremented so,i++ must be 1

final value is " 1 2 1"

Is This Answer Correct ?    1 Yes 3 No

void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?..

Answer / ramya

OUTPUT:
1,2,1

Is This Answer Correct ?    0 Yes 2 No

void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?..

Answer / pratik

answer is 1 1 2 ..
it is an example of stack type ..

Is This Answer Correct ?    0 Yes 4 No

void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?..

Answer / ismail ns

1 1 2

Is This Answer Correct ?    1 Yes 8 No

Post New Answer

More C C++ Errors Interview Questions

UINT i,j; i = j = 0; i = ( i++ > ++j ) ? i++ : i--; explain pls....

5 Answers  


I'm having trouble with coming up with the correct code. Do I need to put a loop? Please let me know if I'm on the right track and what areas I need to correct. I still don't have a good grasp on this programming stuff. Thanks =) The assignment was to write a program using string functions that accepts a coded value of an item and displays its equivalent tag price. The base of the keys: 0 1 2 3 4 5 6 7 8 9 X C O M P U T E R S Sample I/O Dialogue: Enter coded value: TR.XX Tag Price : 68.00

3 Answers   UCB,


how tally is useful?

2 Answers  


How to create a program that lists countries capitals when country is entered? (Terribly sorry, I'm a complete novist to coding with C, am looking for inspiration and general tips on how to code and create this program.)

0 Answers  


Assume that the int variables i and j have been declared, and that n has been declared and initialized. Write code that causes a "triangle" of asterisks of size n to be output to the screen. Specifically, n lines should be printed out, the first consisting of a single asterisk, the second consisting of two asterisks, the third consistings of three, etc. The last line should consist of n asterisks. Thus, for example, if n has value 3, the output of your code should be * ** *** You should not output any space characters. Hint: Use a for loop nested inside another for loop.

2 Answers   HCL,






void main() { int i=7; printf("N= %*d",i,i); }

6 Answers   HCL,


what is run time error?

7 Answers  


Find the error (2.5*2=5) (a) X=y=z=0.5,2.0-5.75 (b) s=15;

3 Answers  


printy(a=3,a=2)

3 Answers  


void main() { int i=5,y=3,z=2,ans; clrscr(); printf("%d",++i + --z + i++ + --i * ++y); i=5,y=3,z=2; ans=++i + --z + i++ + --i * ++y; printf("\n%d",ans); getch(); } Its output is 37 and 31.... Please explain me why its different How it works.....

2 Answers  


char* f() return "hello:"; void main() {char *str=f(); }

1 Answers  


void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?..

32 Answers   College School Exams Tests, CTS, HCL, iGate, SmartData,


Categories