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
What is the difference between specifying a constant variable like with constant keyword and #define it? i.e what is the difference between CONSTANT FLOAT A=1.25 and #define A 1.25
What are c preprocessors?
What is the return type of sizeof?
What is difference between union and structure in c?
Is array a primitive data type in c?
What is console in c language?
How can I get back to the interactive keyboard if stdin is redirected?
number of times a digit is present in a number
the question is that what you have been doing all these periods (one year gap)
Why is main function so important?
What are the different types of C instructions?
what does static variable mean?
What functions are used in dynamic memory allocation in c?
What are different storage class specifiers in c?
What is static function in c?