ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  ERRORS  >>  C C++ Errors
 
 


 

 
 C C++ Errors interview questions  C C++ Errors Interview Questions
 DotNet Errors interview questions  DotNet Errors Interview Questions
 Database Errors interview questions  Database Errors Interview Questions
 Scripts Errors interview questions  Scripts Errors Interview Questions
Question
void main()
{
int i=1;
printf("%d%d%d",i,++i,i++);
}
Cau u say the output....?
 Question Submitted By :: Mariaalex007
I also faced this Question!!     Rank Answer Posted By  
 
  Re: void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?
Answer
# 1
3   3    1
 
Is This Answer Correct ?    20 Yes 5 No
Saurabh Mehra
 
  Re: void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?
Answer
# 2
its .....1 2 2
 
Is This Answer Correct ?    7 Yes 12 No
Ajay
 
 
 
  Re: void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?
Answer
# 3
2 2 1
 
Is This Answer Correct ?    3 Yes 10 No
Rajababu
 
  Re: void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?
Answer
# 4
113
 
Is This Answer Correct ?    1 Yes 9 No
Idds
 
  Re: void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?
Answer
# 5
1 2 3
 
Is This Answer Correct ?    0 Yes 7 No
Kanshi Ram
 
  Re: void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?
Answer
# 6
the output will be 3 3 1.
 
Is This Answer Correct ?    4 Yes 0 No
Vignesh1988i
 
  Re: void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?
Answer
# 7
sorry for not explaining it.

this is due to a concept of STACK which is a DATA STRUCTURE.

take the statement : printf("%d%d%d",i,++i,i++);

this list of variables will be getting stored in the stack. like the way shown:
        i++
        ++i
         i
since the operation of the stack is  LIFO(last in first out)
the process will be done as said as LIFO but while retriving the data it will be printing according to the printf statement so only the output   3 3 1
 
Is This Answer Correct ?    8 Yes 1 No
Vignesh1988i
 
  Re: void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?
Answer
# 8
331
 
Is This Answer Correct ?    2 Yes 0 No
Ravi
 
  Re: void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?
Answer
# 9
1 1 2
 
Is This Answer Correct ?    0 Yes 1 No
Ismail Ns
 
  Re: void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?
Answer
# 10
Yes, but before giving the answer I wanna discuss the question.
In printf() function compiler calculates the values from
right to left (i.e. at first calculates the vale of i++,
then ++i and at last i)but prints the values from left to right.
So compiler at first calculates the value of i++, here i=1
so the value is printed 1 for i++, in the post increment the
value of i becomes 2, but in the pre increment which is ++i,
the value becomes 3, so the value is printed 3 for ++i, now
the value of i is 3, for this reason the value is printed
again 3 for i. But as I said before printf() function prints
from left to right 
so the output will be 3 3 1
 
Is This Answer Correct ?    5 Yes 1 No
Arnob Kumar Pal
 

 
 
 
Other C C++ Errors Interview Questions
 
  Question Asked @ Answers
 
wap for bubble sort  2
printy(a=3,a=2)  3
Given an int variable n that has been initialized to a positive value and, in addition, int variables k and total that have already been declared, use a do...while loop to compute the sum of the cubes of the first n whole numbers, and store this value in total . Thus if n equals 4, your code should put 1*1*1 + 2*2*2 + 3*3*3 + 4*4*4 into total . Use no variables other than n , k , and total .  3
who was the present cheif governor of reserve bank of india SBI3
void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?  10
Given that two int variables, total and amount , have been declared, write a sequence of statements that: initializes total to 0 reads three values into amount , one at a time. After each value is read in to amount , it is added to the value in total (that is, total is incremented by the value in amount ). Instructor's notes: If you use a loop, it must be a for loop. And if you use a loop control variable for counting, you must declare it.  1
Find the error (2.5*2=5) (a) X=y=z=0.5,2.0-5.75 (b) s=15;  3
UINT i,j; i = j = 0; i = ( i++ > ++j ) ? i++ : i--; explain pls....  3
loop1: { x=i<n?(i++):0; printf("%d",i); exit(x); continue; } Error- misplaced continue. Doubt-1.will the exit(x) be executed for all values of x 2.will this statement go out of the program. CMC4
write a profram for selection sort whats the error in it?  1
To generate the series 1+3+5+7+... using C program  5
void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?..  6
Given that two int variables, total and amount, have been declared, write a loop that reads integers into amount and adds all the non-negative values into total. The loop terminates when a value less than 0 is read into amount. Don't forget to initialize total to 0. Instructor's notes: This problem requires either a while or a do-while loop.  1
main() { char c; for(c='A';c<='Z';c++) getch(); }  7
how to convert decimal to binary in c using while loop without using array  7
Given an int variable n that has already been declared and initialized to a positive value, and another int variable j that has already been declared, use a do...while loop to print a single line consisting of n asterisks. Thus if n contains 5, five asterisks will be printed. Use no variables other than n and j .  1
 
For more C C++ Errors Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com