#include <stdio.h>void main(){int a=3;int var1 = - -3;a= 2 + (--a);printf("var1=%d\n",var1);printf("var2=%d",a);}a.Errorb.var1=3 var2=4c.var1=2 var2=-1d.var1=2 var2=4
Question
#include <stdio.h>void main(){int a=3;int var1 = - -3;a= 2 + (--a);printf("var1=%d\n",var1);printf("var2=%d",a);}a.Errorb.var1=3 var2=4c.var1=2 var2=-1d.var1=2 var2=4
Solution
The code provided is written in C language. It first declares an integer variable 'a' and assigns it a value of 3. Then it declares another integer variable 'var1' and assigns it the value of - -3, which is equivalent to 3.
Next, it modifies the value of 'a' by subtracting 1 from it (due to the -- operator) and then adding 2. So, the new value of 'a' becomes 2 + (3-1) = 4.
Finally, it prints the values of 'var1' and 'a' (which is now referred to as 'var2').
So, the output of the program will be:
var1=3 var2=4
Therefore, the correct answer is (b) var1=3, var2=4.
Similar Questions
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.