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


public void A() {
int x;
x = 8;
x *= 4 + 8 / 2;
}
Given the above code, what is the value of "x"?

Answers were Sorted based on User's Feedback



public void A() { int x; x = 8; x *= 4 + 8 / 2; } Given the above code, what is the value o..

Answer / chandusrit

x*=4+8/2 =====> x=x*(4+8/2)
This is correct and the answer is 64

Is This Answer Correct ?    14 Yes 3 No

public void A() { int x; x = 8; x *= 4 + 8 / 2; } Given the above code, what is the value o..

Answer / prasad

answer is 64

Is This Answer Correct ?    10 Yes 3 No

public void A() { int x; x = 8; x *= 4 + 8 / 2; } Given the above code, what is the value o..

Answer / sasi

64 is the correct answer, i will check it practically

Is This Answer Correct ?    7 Yes 1 No

public void A() { int x; x = 8; x *= 4 + 8 / 2; } Given the above code, what is the value o..

Answer / aspdev556

Sorry for the confusion, figured it out.
x = x * 4 + 8 / 2 only multiplies x by 4 not the whole
expression.

Is This Answer Correct ?    5 Yes 1 No

public void A() { int x; x = 8; x *= 4 + 8 / 2; } Given the above code, what is the value o..

Answer / aspdev556

64.
Although if you place the same thing like:
x = x * 4 + 8 / 2;
this yields 36 which was my first guess.
How come its producing two different results? Aren't the
assignment statements suppose to get the same result?

Is This Answer Correct ?    4 Yes 2 No

public void A() { int x; x = 8; x *= 4 + 8 / 2; } Given the above code, what is the value o..

Answer / vinodh kumar

operator precedence...
* / % + -

x = x * 4 + 8 / 2;

(i) x*(4+(8/2))
(ii) x*(4+4)
(iii) x*8 => Replace x with 8 as per question :P
Ans:64

http://www.blackwasp.co.uk/CSharpOperatorPrecedence.aspx

Is This Answer Correct ?    2 Yes 2 No

public void A() { int x; x = 8; x *= 4 + 8 / 2; } Given the above code, what is the value o..

Answer / m upendra reddy

i t will foloows the rule of BADMAS
THAT'S why first it caliculate ,like first checks is there
any divisions then caliculate and then multiplictations


x=x*4+8/2;
8/2=4;
then
x=x*4+4;
then x=x*4;==>8*4=32;
now
x=32+4;===>x=36

Is This Answer Correct ?    2 Yes 6 No

public void A() { int x; x = 8; x *= 4 + 8 / 2; } Given the above code, what is the value o..

Answer / nitin

x=8;
x=12/2*8;
x=6*8;
x=48;

The Anwere is 48

Is This Answer Correct ?    0 Yes 16 No

Post New Answer

More C Sharp Interview Questions

Can You Prevent Your Class From Being Inherited By Another Class?

0 Answers   Siebel Systems,


What are the advantages of using c#?

0 Answers  


Is friend a constructor?

0 Answers  


What is default constructor in c#?

0 Answers  


what is IFormatable

0 Answers   Wipro,


What does async mean in c#?

0 Answers  


This is Kishore i am MCA graduate i have percentage less(52%) in my 10th still i completed .NET course any body tell me how to put fake experience with my BSC degree if you do not mind tell me some fake certificates giving consultencies names in Chennai,Bangalore

5 Answers  


What is difference between C# and VB.NET?

0 Answers   CDC,


Explain About stateless and state full web service

0 Answers   Digital GlobalSoft,


Why data types are important in c#?

0 Answers  


What is difference between c sharp and c#?

0 Answers  


What is int32?

0 Answers  


Categories