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


Please Help Members By Posting Answers For Below Questions

Was 2000 a leap year?

616


Explain what is a static function?

626


write a program to print largest number of each row of a 2D array

1861


difference between Low, Middle, High Level languages in c ?

1624


What is a pointer and how it is initialized?

596






Why doesnt the call scanf work?

656


in iso what are the common technological language?

1624


What is the use of a semicolon (;) at the end of every program statement?

755


`write a program to display the recomended action depends on a color of trafic light using nested if statments

1624


What language is windows 1.0 written?

563


What is the difference between memcpy and memmove?

593


how many types of operators are include in c language a) 4 b) 6 c) 8 d) 12

641


write an algorithm to display a square matrix.

2213


what value is returned to operating system after program execution?

1591


Declare the structure which contains the following members and write in C list of all students who score more than 75 marks. Roll No, Name, Father Name, Age, City, Marks.

652