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 return type in c?
write a program to print calender using for loop.
Can we change the value of static variable in c?
what is pointer?
13 Answers HCL, TCS,
What is getch c?
How do I round numbers?
how many times does the loop iterated ? for (i=0;i=10;i+=2) printf("Hi\n");
Write a program to print fibonacci series using recursion?
what are the facialities provided by you after the selection of the student.
What is typeof in c?
any "C" function by default returns an a) int value b) float value c) char value d) a & b
What is enumerated data type in c?