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 |
How are portions of a program disabled in demo versions?
Why is sizeof () an operator and not a function?
What is sizeof return in c?
What is union in c?
Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?
logic for x=y^n
Find the second largest element in an array with minimum no of comparisons and give the minimum no of comparisons needed on an array of size N to do the same.
Why c language?
What is difference between stdio h and conio h?
write a program in reverse the string without using pointer,array,global variable declaration,lib fun only using a function?
What are logical errors and how does it differ from syntax errors?
What is variable and explain rules to declare variable in c?