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...


what is the value of b
if a=5;
b=++a + ++a

Answers were Sorted based on User's Feedback



what is the value of b if a=5; b=++a + ++a ..

Answer / kuldeep

13

Is This Answer Correct ?    151 Yes 77 No

what is the value of b if a=5; b=++a + ++a ..

Answer / sagar

here in b=++a + ++a;
a
Initial Value 5
First Prefix 6
Second Prefix 7
Final Equation b = 7 + 7 = 14...
So,correct answer is 14....

if the equation was as below:
c=++a;//a==6
d=++a;//a=7
b=c+d;//b=6+7=13
then b==13...

Is This Answer Correct ?    97 Yes 29 No

what is the value of b if a=5; b=++a + ++a ..

Answer / guru1985

b=++a(6) + ++a(7)
b=6+7
=13

Is This Answer Correct ?    83 Yes 57 No

what is the value of b if a=5; b=++a + ++a ..

Answer / madhu cherukuri

a=5
b=++a +++a;
ANS:14
in this case the data will be storing in CPU register so the
result is 14 only.

volatile int a=5;
b=++a + ++a;
ANS:13
the data will be stored in directly memory

Is This Answer Correct ?    33 Yes 15 No

what is the value of b if a=5; b=++a + ++a ..

Answer / naresh

Not a very tough question. Important thing to note that in
any expression pre increment operator has a higher prority
than arithemetic operator as a result value of a is
increment is first two times then value of b is evaluated.
So b = 7*7 = 14.
in first ++a we get a=6
in next ++a we get a=7
and b=7+7=14

This question will result in same output for most of the
compilers, but some rare compiler may produce an entire
diffrenent parse tree resulting in an undefined result

Is This Answer Correct ?    28 Yes 13 No

what is the value of b if a=5; b=++a + ++a ..

Answer / deepika katiyar

13

Is This Answer Correct ?    36 Yes 24 No

what is the value of b if a=5; b=++a + ++a ..

Answer / anupam

13

Is This Answer Correct ?    25 Yes 16 No

what is the value of b if a=5; b=++a + ++a ..

Answer / anup dixit

13 is the correct answers. I'm attaching here a small java
program which proves this:

The program is:

------------------------------------------------------------

public class TestAddition
{
public static void main(String[] args)
{
int a=5;

System.out.println("1..Before a was : "+a);

int b = ++a + ++a;

System.out.println("Final a was : "+a+ ", int b =
++a + ++a is: "+b);

a=5;

System.out.println("2..Before a was : "+a);
int c= ++a+(++a);

System.out.println("Final a was : "+a+", int c=
++a+(++a) is: "+c);

}
}

------------------------------------------------------------

The output is:

------------------------------------------------------------

1..Before a was : 5
Final a was : 7, int b = ++a + ++a is: 13
2..Before a was : 5
Final a was : 7, int c= ++a+(++a) is: 13

Is This Answer Correct ?    15 Yes 10 No

what is the value of b if a=5; b=++a + ++a ..

Answer / kaps

IT is defenetly 14...Ans = 14
Explanation:
Because ++a = 6
then again ++a = 7
Now compiler replace the both value with 7 (because of both
are of value of a).
So 7+7 = 14.

It is tested on turbo C...
try with adding one more ++a will give u ans 24(8+8+8) for
++a + ++a + ++a.

Is This Answer Correct ?    8 Yes 3 No

what is the value of b if a=5; b=++a + ++a ..

Answer / harshfire92

b=14

Is This Answer Correct ?    55 Yes 51 No

Post New Answer

More C Interview Questions

how to execute a program using if else condition and the output should enter number and the number is odd only...

0 Answers  


What are the application of c?

0 Answers  


what is the code for getting the output as * ** ***

5 Answers   Caritor,


How do you initialize function pointers? Give an example?

3 Answers  


What is a program flowchart and explain how does it help in writing a program?

0 Answers  


Give differences between - new and malloc() , delete and free() ?

0 Answers   Genpact,


Why main is not a keyword in c?

0 Answers  


What is a pointer in c plus plus?

0 Answers  


What does typeof return in c?

0 Answers  


Explain the difference between #include "..." And #include <...> In c?

0 Answers  


Define Array of pointers.

0 Answers  


What does printf does?

0 Answers  


Categories