Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


#include<stdio.h>
main()
{
int a=1;
int b=0;
b=++a + ++a;
printf("%d %d",a,b);
}

Answers were Sorted based on User's Feedback



#include<stdio.h> main() { int a=1; int b=0; b=++a + ++a; printf("%d %d",a,b);..

Answer / banavathvishnu

let consider the statement
b = ++a + ++a;
++a will be 2
++a again will be 3
now replace its value in the expression
b = a + a = 3+3=6
hence a is 3 and b is 6

Is This Answer Correct ?    26 Yes 12 No

#include<stdio.h> main() { int a=1; int b=0; b=++a + ++a; printf("%d %d",a,b);..

Answer / aditya gupta

Let me make this more clear... infact if the case is of
pre-increment:

1- find all the variables of pre-increment, and compute them
2- do the assignment.

for example, what I do:
main()
{
int a=1; // initialization
int b=0; // initialization

b=++a + ++a; // find the pre-increment i.e. 2 increments of
'a' so now 'a' in this step will be incremented by 2 so now
'a' will contain 1+2=3. so now a=3. Again before assignment
compute 'a+a' which is '3+3'=6

printf("%d %d",a,b); //3 6

}

Just a trick:- always compute the pre-increments in the same
step...

If I say b= ++a + ++a; answer is 3 and 6
If I say b= ++a + a++; answer is 3 and 4 because in this
line one pre-increment is there. So now '++a + a++'= "2 + 2"



Thanks!!
Aditya Gupta

Is This Answer Correct ?    8 Yes 2 No

#include<stdio.h> main() { int a=1; int b=0; b=++a + ++a; printf("%d %d",a,b);..

Answer / m.karthiga

3 6

Is This Answer Correct ?    19 Yes 15 No

#include<stdio.h> main() { int a=1; int b=0; b=++a + ++a; printf("%d %d",a,b);..

Answer / ashok

initially a=1,b=0
++a=2 //1+1=2
++a=3 //2+1=3
b=2+3=5
answer:a=3 b=5

Is This Answer Correct ?    6 Yes 4 No

#include<stdio.h> main() { int a=1; int b=0; b=++a + ++a; printf("%d %d",a,b);..

Answer / anand

answer should be 3 5
b = 2 + 3
b = ++a + ++a
here the compiler will work as below

b = ++a + 2
thn
b = 3 + 2
thn
b = 5

Is This Answer Correct ?    9 Yes 10 No

#include<stdio.h> main() { int a=1; int b=0; b=++a + ++a; printf("%d %d",a,b);..

Answer / vijay r15

ans 3 6

Let me explain
First a=1&b=0
b=++a + ++a;

The operation will be as
b= ++1 + ++a
=2 + ++a
=2 + ++2
=2 + 3=a+a now a=3
Remember here is the trick
Now b= a + a
I.e b=3+3=6

Got it

Vijay r15
For any clarification mail to
raj.vijay55@gmail.com

Is This Answer Correct ?    2 Yes 4 No

#include<stdio.h> main() { int a=1; int b=0; b=++a + ++a; printf("%d %d",a,b);..

Answer / sas

2 5

Is This Answer Correct ?    0 Yes 6 No

Post New Answer

More C Interview Questions

What is the use of a static variable in c?

0 Answers  


What are data types in c language?

0 Answers  


i=20,k=0; for(j=1;j<i;j=1+4*(i/j)) { k+=j<10?4:3; } printf("%d", k);

8 Answers   HCL,


What is the value of h?

0 Answers  


Explain how many levels deep can include files be nested?

0 Answers  


char p="data"; printf(p);

2 Answers  


User define function contain thier own address or not.

2 Answers  


An integer that indentifies the position of a data item in a sequence of data items a) value b) number c) index d) all of the above

0 Answers  


In c programming typeing to occupy the variables in memory space. if not useing the variable the memory space is wasted.ok, how to avoid the situation..? (the variable is used & notused)

0 Answers   Wipro,


any limit on the number of functions that might be present in a C program a) max 35 functions b) max 50 functions c) no limit d) none of the above

0 Answers  


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

4 Answers   Vernalis, Vernalis Systems,


What is an lvalue in c?

0 Answers  


Categories