Give the logic for this
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a=10,b;
b=++a + ++a;
printf("%d", b);
getch();
}
Output: 24......How?
Answers were Sorted based on User's Feedback
Answer / suman halder
++a is an unary expression which signifies pre-increment operation...so ,pre-increment will be evaluated before the binary operation takes place..
b=++a + ++a;
here,a will be incremented twice and then binary operation is performed...
so,
b=12+12 which produces 24...
| Is This Answer Correct ? | 6 Yes | 3 No |
in first increment the a will become 11. And the second
increment the a will become 12. b=++a + ++a ; have same
variable so b=12+12=24
| Is This Answer Correct ? | 5 Yes | 5 No |
What is memory leak in c?
what is call by value and call by reference
Write code for finding depth of tree
What are header files in c?
What is the right type to use for boolean values in c? Is there a standard type?
The operation of a stair case switch best explains the a) or operation b) and operation c)exclusive nor operation d)exclusive or operation Which of the following is/are syntactically correct? a) for(); b) for(;); c) for(,); d) for(;;);
1 Answers HCL, Public Service Commission,
What is array of structure in c programming?
When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?
why we use "include" word before calling the header file. is there any special name for that include??????
please give me some tips for the placement in the TCS.
What is the use of structure padding in c?
what is the meaning of 'c' language