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



Give the logic for this #include<stdio.h> #include<conio.h> void main() { clrscr..

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

Give the logic for this #include<stdio.h> #include<conio.h> void main() { clrscr..

Answer / krishnaraogm

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

Post New Answer

More C Interview Questions

How does pointer work in c?

0 Answers  


How will you write a code for accessing the length of an array without assigning it to another variable?

0 Answers  


Explain the use of function toupper() with and example code?

0 Answers  


Convert the following expression to postfix and prefix X $ Y Z - M + N + P / Q / (R + S)

2 Answers  


Explain bit masking in c?

0 Answers  


Explain how do you list files in a directory?

0 Answers  


the output will be #include<stdio.h> int main () { int i; i = 9/2; printf("%i",i); return 0; }

4 Answers   CMC, TCS,


write a program to find the frequency of a number

4 Answers   Infosys,


main() { unsigned int k = 987 , i = 0; char trans[10]; do { trans[i++] =(char) (k%16 > 9 ? k%16 - 10 + 'a' : '\0' ); } while(k /= 16); printf("%s\n", trans); }

4 Answers   Vector,


what is difference between array and structure?

44 Answers   College School Exams Tests, CTS, Google, HCL, IBM, Motorola, TCS,


What does the characters “r” and “w” mean when writing programs that will make use of files?

0 Answers  


What is c value paradox explain?

0 Answers  


Categories