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

main() { int *ptr=(int*)malloc(sizeof(int)); *ptr=4; printf("%d",(*ptr)+++*ptr++); }

3 Answers   GNITC,


void main() { int i=i++,j=j++,k=k++; printf(“%d%d%d”,i,j,k); }

1 Answers  


what is variable length argument list?

2 Answers  


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

1 Answers  


find A^B using Recursive function

2 Answers  






why is printf("%d %d %d",i++,--i,i--);

4 Answers   Apple, Cynity, TCS,


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

2 Answers   HCL,


Write a complete program that consists of a function that can receive two numbers from a user (M and N) as a parameter. Then print all the numbers between the two numbers including the number itself. If the value of M is smaller than N, print the numbers in ascending flow. If the value of M is bigger than N, print the numbers in descending flow. may i know how the coding look like?

2 Answers  


Write a C program to print look and say sequence? For example if u get the input as 1 then the sequence is 11 21 1211 111221 312211 12112221 .......(it counts the no. of 1s,2s etc which is in successive order) and this sequence is used in run-length encoding.

1 Answers  


int i,j; for(i=0;i<=10;i++) { j+=5; assert(i<5); }

3 Answers   Cisco, HCL,


can you use proc sql to manpulate a data set or would u prefer to use proc report ? if so why ? make up an example and explain in detail

0 Answers   TCS,


main() { int i, n; char *x = “girl”; n = strlen(x); *x = x[n]; for(i=0; i<n; ++i) { printf(“%s\n”,x); x++; } }

2 Answers  


Categories