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

What is static memory allocation? Explain

634


i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical

1848


What is the advantage of a random access file?

644


Explain the use of bit fieild.

719


What is the use of typedef in c?

594






What is bash c?

564


what is the role you expect in software industry?

1660


What is getch c?

863


What is the advantage of c?

615


How to create struct variables?

597


What is s or c?

604


What do you mean by dynamic memory allocation in c?

656


Write a C program to count the number of email on text

1422


Why header file is used in c?

583


Explain how do you sort filenames in a directory?

616