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 / raman

ans would be 14
because...
if u dont believe tn run the program
u'll understand

Is This Answer Correct ?    5 Yes 3 No

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

Answer / shashikanth

if a=5;
b=++a+++a;

initial value a=5
first prefix 6
second prefix 7
final value b=7+7
b=14

ans 14

Is This Answer Correct ?    4 Yes 2 No

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

Answer / prasoon

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

Is This Answer Correct ?    9 Yes 8 No

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

Answer / ranvir kumar singh

Answer would be 13

Is This Answer Correct ?    4 Yes 3 No

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

Answer / kumkum

13

Is This Answer Correct ?    3 Yes 2 No

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

Answer / rd

its 13
initial value: 5

++a : 6
again (++a): 7

so it is (7+6) 13...and there shouldn't be any doubt about it.

Is This Answer Correct ?    14 Yes 14 No

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

Answer / sandeep

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int a=5,b;
if(a==5)
{
b=++a + ++a;
Console.WriteLine(b);
Console.ReadLine();
}
}
}
}

answer is 13

Is This Answer Correct ?    0 Yes 0 No

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

Answer / nitin kumar

14

Is This Answer Correct ?    0 Yes 0 No

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

Answer / thakur

14

Is This Answer Correct ?    0 Yes 0 No

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

Answer / invader007

The output will be 14.
i.e. The the value of b is 14.
Explanation:
Consider Expression (b = ++a + ++a;)
Initially the value of a is 5. After the first pre increment operator it will be 6 and after second one it becomes 7. So we guess the expression evaluated as (b = 6 + 7 i.e. b = 13). But wait... In C Programming Language ++a is nothing but a = a + 1, am I right? Ofcourse it's right. Now consider the presedense of pre increment operator over addition operator, Compiler first's evaluate both ++a and the perform addition. So first ++a evaluated to 6 i.e. Now a = 6 then second ++a evaluated as 7 i.e. Now a = 7 and overwrite the old value of a. So compiler evaluated our expression as
b = (a = a +1) + (a = a+1); first compiler assign a = 6 and then a = 7 so our expression becomes b = 7 + 7 as same variable can't holds two different values at a time. And finally our main out will be 14.
I hope now you understand it.
Thnk you!

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

What is the 'named constructor idiom'?

0 Answers  


How can I split up a string into whitespace-separated fields?

0 Answers  


How do you initialize function pointers? Give an example?

3 Answers  


Explain modulus operator. What are the restrictions of a modulus operator?

0 Answers  


2. What is the function of ceil(X) defined in math.h do? A)It returns the value rounded down to the next lower integer B)it returns the value rounded up to the next higher integer C)the Next Higher Value D)the next lower value

3 Answers   Accenture,


Difference between C and Embedded C?

1 Answers  


Explain threaded binary trees?

0 Answers  


write a function that accepts an integer/char array and an search item.If the search item is there in the array return position of array and value else return -1.without using other array,without sorting,not to use more than one loop?

3 Answers   Mind Tree,


where does malloc() function get the memory?

1 Answers  


How to set file pointer to beginning c?

0 Answers  


How can I sort a linked list?

0 Answers  


prog for 1st five prime numbers in 2^x - 1

0 Answers  


Categories