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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Do you know null pointer?

612


What are the scope of static variables?

601


What is variables in c?

609


What is the explanation for prototype function in c?

571


What is queue in c?

578






please can any one suggest me best useful video tutorials on c i am science graduate.please help me.u can email me to sas29@in.com

1329


A collection of data with a given structure for excepting storing and providing on demand data for multiple users a) linked list b) datastructer c) database d) preprocessor

623


C program execution always begins with a) #include b) comment (/*-------*/) c) main() d) declaration instructions

612


What is return in c programming?

517


Explain can the sizeof operator be used to tell the size of an array passed to a function?

597


What are header files why are they important?

582


What is the difference between malloc() and calloc() function in c language?

604


What is modeling?

647


application attempts to perform an operation?

1495


Define recursion in c.

702