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

What are the application of void data type in c?

0 Answers  


What is local and global variable in c?

0 Answers  


Explain the difference between the local variable and global variable in c?

0 Answers  


program in c to print 1 to 100 without using loop

9 Answers   Wipro,


Write a C program to find the smallest of three integers, without using any of the comparision operators.

7 Answers   TCS,






Write a program to find the number of times that a given word(i.e. a short string) occurs in a sentence (i.e. a long string!). Read data from standard input. The first line is a single word, which is followed by general text on the second line. Read both up to a newline character, and insert a terminating null before processing. Typical output should be: The word is "the". The sentence is "the cat sat on the mat". The word occurs 2 times.

0 Answers  


What are comments and how do you insert it in a C program?

0 Answers  


What is pointer to pointer in c language?

0 Answers  


Write a C program to convert an integer into a binary string?

1 Answers  


write a program which will count occurance of a day between two dates.

1 Answers   IonIdea,


Which function in C can be used to append a string to another string?

0 Answers  


write a c program to accept a given integer value and print its value in words

4 Answers   Vernalis, Vernalis Systems,


Categories