what is the output of below

int n=10;
(n++)++;
printf("%d",n);

Answers were Sorted based on User's Feedback



what is the output of below int n=10; (n++)++; printf("%d",n);..

Answer / abhijeet kankani

L-value required

Is This Answer Correct ?    22 Yes 1 No

what is the output of below int n=10; (n++)++; printf("%d",n);..

Answer / kirankumaryakkala

ans. error:Lvalue required
why? Lvalue means leftside assignment value,
here, first it goes to increment on N, again it is going to
increment, before going to increment second time, you should
allocate one varibale that holds the first time increment
value, other wise from where to it increment...

Is This Answer Correct ?    11 Yes 1 No

what is the output of below int n=10; (n++)++; printf("%d",n);..

Answer / deepak kumar

error : lvalue required.

n++ return 10 and after that n will increase to 1.
so now n=11
but next operation (postfix operator) is performing on
constant value 10 which is returned by (n++) operation.
it actually try to assign 11 to constant value 10. it is not
possible .
firstly we have to store it in a variable and then increment
can take place..

Is This Answer Correct ?    9 Yes 2 No

Post New Answer

More C Interview Questions

who is the founder of c

19 Answers   College School Exams Tests, HP,


What is a protocol in c?

0 Answers  


Whats s or c mean?

0 Answers  


What does it mean when a pointer is used in an if statement?

0 Answers  


What is typedef?

1 Answers  






What is array in c with example?

0 Answers  


An interactive c program to read basic salary of 15 persons. each person gets 25% of basic as HRA, 15%of basic as conveyance allowances, 10%of basic as entertainment allowances.The total salary is calculated by adding basic+HRA+CA+EA.Calculate how many out of 15 get salary above 10,000.Rs also print the salary of each employee

2 Answers  


what is out put of the following code? #include class Base { Base() { cout<<"constructor base"; } ~Base() { cout<<"destructor base"; } } class Derived:public Base { Derived() { cout<<"constructor derived"; } ~Derived() { cout<<"destructor derived"; } } void main() { Base *var=new Derived(); delete var; }

3 Answers   Honeywell,


WHAT IS C?

6 Answers  


what is compiler

6 Answers  


Which control loop is recommended if you have to execute set of statements for fixed number of times?

0 Answers  


What is #include stdlib h?

0 Answers  


Categories