Note 1

Take Note:

Take a note while surfing.





Note With Ink

Give your Note a Colorful Tag.




Easy to Access

Stay on same information and in Sync wherever you are.

Note 2

Take Note:

Organize your information,It may take Shape.





Think With Ink

Differ your Content by Color.




Easy to Access

Easy to pull up your content from anywhere anytime.

Note 3

Take Note:

Don't Let information to miss,Because it take shape





Note With Ink

Simple an Easy Way to take a note.




Easy to Access

Get the same in next visit.

C Programming :: Increment-Decrement

Home > C Programming > Increment-Decrement > General Questions

1. What will be output of the following "c" code?

#include
void main() {
int i=-1,j=-1,k=0,l=2,m;
m = i++ && j++ && k++ || l++;
printf("%d %d %d %d %d",i,j,k,l,m);
}

Answer: 0 0 1 3 1

Explanation:

=>Logical operations always give a result of 1 or 0 .
=> Logical AND (&&) operator has higher priority over the logical OR (||) operator.

So the expression i++ && j++ && k++ is executed first. The result of this expression is 0 (-1 && -1 && 0 = 0)

Workspace

Tags:

No Tags on this question yet!

2. What will be output of the following "c" code?

#include
void main(){
int i=5,j=10,num;
num=(++i,++j,i+j);
printf("%d %d %d",num,i,j);
}

Answer: 17 6 11

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

3. What will be output of the following "c" code?

#include
void main()
{
int i=5;
printf("%d",i+++++i);
}

Answer: Compiler Error

Explanation:

The expression i+++++i is parsed as i ++ ++ + i which is an illegal combination of operators.

Workspace

Tags:

No Tags on this question yet!

4. What will be output of the following "c" code?

#include
#include
void main(){
int a,i=4;
a=- -i+- -i+- -5;
printf("%d %d",a,i);
}

Answer: 13 4

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

5. What will be output of the following "c" code?

#include
int main()
{
int i=5,j=6,z;
printf("%d",i+++j);
return 0;
}

Answer: 11

Explanation:

the expression i+++j is treated as (i++ + j)

Workspace

Tags:

No Tags on this question yet!

6. What will be output of the following "c" code?

#include
void main(){
int num,a=10;
num=a--- -a--;
printf("%d %d",num,a);
}

Answer: 20 8

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

7. What will be output of the following "c" code?

#include
#define plus +
#define minus +plus
int main(){
long x,i=3;
x=++i;
printf("%ld",x);
return 0;
}

Answer: 4

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

8. What will be output of the following "c" code?

#include
void main(){
int a[]={5,10,15};
int i=0,num;
num=a[++i]+ ++i+(++i);
printf("%d",num);
}

Answer: 6

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

9. What will be output of the following "c" code?

#include
void main(){
int num,a=5;
num=---a;
printf("%d %d",num,a);
}

Answer: Compilation error

Explanation:

error: invalid lvalue in decrement

Workspace

Tags:

No Tags on this question yet!

10. What will be output of the following "c" code?

#include
int main()
{
int i=5;
printf("%d %d %d %d %d %d",i++,i--,++i,--i,i);
return 0;
}

Answer: 4 5 5 5 5

Explanation:

The arguments in a function call are pushed into the stack from left to right.
The evaluation is by popping out from the stack. and the evaluation is from right to left, hence the result.

Workspace

Tags:

No Tags on this question yet!