what is the output of following program ?
void main()
{
int i=5;
printf("%d %d %d %d %d ",i++,i--,++i,--i,i);
}

Answers were Sorted based on User's Feedback



what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d &qu..

Answer / sameeksha agrawal

ya i can tell u abt d ans ..the reasn behind it x++ is
example of post increament in which frstly value of any
variable is prnt thn oprtr r prfrmed and the oprtions r
perfrmd frm right side...

Is This Answer Correct ?    7 Yes 2 No

what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d &qu..

Answer / sandeep gupta

Friends, actually the output is compiler dependent. Never
give any specific answer in this type of questions because C
does not provide any format in evaluation order of postfix
and prefix expressions when passed to any functions like
printf() eg. fun1(i++,i) may pass fun1(5,6) in some
compilers and fun1(5,5) in another. So it totally depends on
what compiler we're using.

Is This Answer Correct ?    4 Yes 0 No

what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d &qu..

Answer / sameeksha agrawal

45545

Is This Answer Correct ?    9 Yes 6 No

what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d &qu..

Answer / jalp

Here if i do it manually then i got 44545 but compiler shows
me : 45545

Can any body show the stack process that how it execute
internally,

And also reply through mail.
Thanks.

Is This Answer Correct ?    6 Yes 5 No

what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d &qu..

Answer / jalp

That i know .. I want to know the stack process , how it
internally works .. if you elaborate through step then
please explain it ..

Thanks.

Is This Answer Correct ?    2 Yes 1 No

what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d &qu..

Answer / kavsac

Guys,
There is something, I wanna add on. The above result occurs only in windows, in Unix its 56656

Is This Answer Correct ?    2 Yes 1 No

what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d &qu..

Answer / shenbagam

in c its left to right operation will be perfomed by
compiler..... so take this

int i=5;
printf("%d %d %d %d %d ",i++,i--,++i,--i,i);


i=5;

--i=4; after tis the value of i=4 only;

because --i will decrement the value of i, and then return the decremented value.

++i=5; after this the value of i=5;

because ++i will increment the value of i, and then return the incremented value.

i--=5; after this the value of i=4;

because will decrement the value of i, but return the pre-defind value of i. so i=5 before the step na?.....

i++=4; after this the value of i=5;

because will increment the value of i, but return the pre-defined value of i.so i=4 before the step na?...


so only the result will be like 45545 this.......


int i=5;
printf("%d %d %d %d %d ",i++,i--,++i,--i,i);

after the step if u print i; the value must be 5


only......... so the doubt will be cleared aha?............

all the best:):):):).

Is This Answer Correct ?    4 Yes 3 No

what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d &qu..

Answer / sameeksha agrawal

no Kavsac u r wrng try again its answer...

Is This Answer Correct ?    0 Yes 0 No

what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d &qu..

Answer / sameeksha agrawal

sry u r totally wrng cz c is structrd progrmmmng languaga

Is This Answer Correct ?    0 Yes 0 No

what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d &qu..

Answer / sindhu

Answer:after compilation i got 45545.... but if i consider it from left to right in manual my answer is 55454...

i want clear xplanation for tis program...

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Code Interview Questions

write a program to find out roots of quadratic equation "x=-b+-(b^2-4ac0^-1/2/2a"

2 Answers  


create a login program that ask username and password. if you input username or password 3 times wrong, the program will terminate else the program will prompt a message "congratulations"

2 Answers  


main() { static int var = 5; printf("%d ",var--); if(var) main(); }

1 Answers  


main() { int i; clrscr(); 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

1 Answers   HCL,


void ( * abc( int, void ( *def) () ) ) ();

1 Answers  






Predict the Output: int main() { int *p=(int *)2000; scanf("%d",2000); printf("%d",*p); return 0; } if input is 20 ,what will be print

2 Answers  


What is the hidden bug with the following statement? assert(val++ != 0);

1 Answers  


main() { signed int bit=512, i=5; for(;i;i--) { printf("%d\n", bit = (bit >> (i - (i -1)))); } } a. 512, 256, 128, 64, 32 b. 256, 128, 64, 32, 16 c. 128, 64, 32, 16, 8 d. 64, 32, 16, 8, 4

2 Answers   HCL,


How to swap two variables, without using third variable ?

104 Answers   AB, ADP, BirlaSoft, Cisco, Cygnet Infotech, HCL, Hewitt, Honeywell, HP, IBM, Infosys, Manhattan, Microsoft, Mobius, Percept, Satyam, SofTMware, TCS, Wipro, Yamaha,


Write, efficient code for extracting unique elements from a sorted list of array. e.g. (1, 1, 3, 3, 3, 5, 5, 5, 9, 9, 9, 9) -> (1, 3, 5, 9).

13 Answers   Intel, Microsoft, TCS,


How can I Create a C program in splitting set of characters to specific subsets. Example: INPUT SET OF CHARACTERS: Therefore, my dear brothers and sisters, stand firm. Let nothing move you. Always give yourselves fully to the work of the Lord, because you know that your labor in the Lord is not in vain. SPLIT INTO HOW MANY CHARACTERS PER SUBSETS: 10 OUTPUT: Therefore, my dear b rothers an d sisters, stand fir m. Let not hing move you. Alway s give you rselves fu lly to the work of t he Lord, b ecause you know that your labo r in the L ord is not in vain.

0 Answers  


struct point { int x; int y; }; struct point origin,*pp; main() { pp=&origin; printf("origin is(%d%d)\n",(*pp).x,(*pp).y); printf("origin is (%d%d)\n",pp->x,pp->y); }

1 Answers  


Categories