Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


main()

{

int i=5;

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

}

Answers were Sorted based on User's Feedback



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

Answer / abdul ahad

45545

because the expiration will executed from right to left and will print from left to right.

at the execution time from right i=5,--i=4,++i=5,i--=5 then decremented to4,now i++=4 ,then incremented to 5.

So the output will be left to right 45545

Is This Answer Correct ?    105 Yes 60 No

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

Answer / prashant nair

Ans: It really much more depend on compiler.


The logic/rules made should take us to the answer 45545 but compiler does also give answer as 45555 :O 

source:
http://code.hackerearth.com/bddbb9e
http://ideone.com/t5fbbd

Is This Answer Correct ?    45 Yes 9 No

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

Answer / susie

Answer :

45545

Explanation:

The arguments in a function call are pushed into
the stack from left to right. The evaluation is by popping
out from the stack. and the evaluation is from right to
left, hence the result.

Is This Answer Correct ?    21 Yes 11 No

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

Answer / jaya

ans:- 45545

Is This Answer Correct ?    13 Yes 7 No

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

Answer / rishit

And will be
4 5 5 4 5 and 1 garbage value as there are
6 %d in printf statement

Is This Answer Correct ?    7 Yes 2 No

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

Answer / moschops

This is UNSPECIFIED BEHAVIOUR. It's possible to work out exactly what your particular compiler decided to do this one particular time, but other compilers are free to do it differently (and probably will). Put the code into some different compilers and you'll see different results. The order that parameters are evaluated is unspecified and left up to the compiler.

If you can explain what the compiler happens to do this one particular time, that's nice but completely useless, but anyone who actually wrote code like this should be fired.

Is This Answer Correct ?    10 Yes 6 No

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

Answer / dharmendra

(i++,i--,++i,--i,i)
(4 , 5, 5 , 4 ,5)

explanation:
executed from right to left
and
print left to right.

Is This Answer Correct ?    11 Yes 7 No

Post New Answer

More C Code Interview Questions

How to return multiple values from a function?

7 Answers  


main() { int i = 0xff ; printf("\n%d", i<<2); } a. 4 b. 512 c. 1020 d. 1024

2 Answers   HCL,


main() { float me = 1.1; double you = 1.1; if(me==you) printf("I love U"); else printf("I hate U"); }

1 Answers  


What is the problem with the following code segment? while ((fgets(receiving array,50,file_ptr)) != EOF) ;

1 Answers  


int aaa() {printf(“Hi”);} int bbb(){printf(“hello”);} iny ccc(){printf(“bye”);} main() { int ( * ptr[3]) (); ptr[0] = aaa; ptr[1] = bbb; ptr[2] =ccc; ptr[2](); }

1 Answers  


#include<stdio.h> main() { int i=1,j=2; switch(i) { case 1: printf("GOOD"); break; case j: printf("BAD"); break; } }

1 Answers  


String reverse with time complexity of n/2 with out using temporary variable.

10 Answers   NetApp, Symantec,


Cluster head selection in Wireless Sensor Network using C programming language.

0 Answers  


What are the following notations of defining functions known as? i. int abc(int a,float b) { /* some code */ } ii. int abc(a,b) int a; float b; { /* some code*/ }

1 Answers  


void main() { while(1){ if(printf("%d",printf("%d"))) break; else continue; } }

1 Answers  


main() { int i=10,j=20; j = i, j?(i,j)?i:j:j; printf("%d %d",i,j); }

2 Answers   Adobe, CSC,


write a c program to Create a registration form application by taking the details like username, address, phone number, email along with password and confirm password (should be same as password).Ensure that the password is of 8 characters with only numbers and alphabets. Take such details for 5 users and display the details. In place of password display “****”. (Use Structures).

0 Answers   CDAC, College School Exams Tests,


Categories