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?
Answer Posted / 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 |
Post New Answer View All Answers
How can I trap or ignore keyboard interrupts like control-c?
What are the functions to open and close file in c language?
Write a program to input the price of 1 burger and the number of burgers eaten by a group of friends .print the total amount to be paid by the group?
Write a program to check prime number in c programming?
Why is main function so important?
Explain the advantages and disadvantages of macros.
What are the scope of static variables?
What is string in c language?
What is the condition that is applied with ?: Operator?
What is the difference between the local variable and global variable in c?
Difference between MAC vs. IP Addressing
What is break in c?
How do we make a global variable accessible across files? Explain the extern keyword?
Why n++ execute faster than n+1 ?
What is omp_num_threads?