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 does c value mean?
What is Dynamic memory allocation in C? Name the dynamic allocation functions.
which of the following statement is wrong a) mes=123.56; b) con='T'*'A'; c) this='T'*20; d) 3+a=b;
What is the use of structure padding in c?
How are pointers declared in c?
What is a 'null pointer assignment' error?
What is the difference between functions abs() and fabs()?
Write a program to find the biggest number of three numbers in c?
Can you write the function prototype, definition and mention the other requirements.
Wt are the Buses in C Language
Difference between goto, long jmp() and setjmp()?
What is the difference between break and continue?
What is #define in c?
What is character constants?
What is a c token and types of c tokens?