Showing posts with label increment operator. Show all posts
Showing posts with label increment operator. Show all posts

Sunday, 6 November 2011

Predict the output or error(s) for the following:

 #include<stdio.h>

main()

{

char s[]={'a','b','c','\n','c','\0'};


char *p,*str,*str1;


p=&s[3];


str=p;


str1=s;


printf("%d",++*p + ++*str1-32);


}

Answer:

77


Explanation:

Friday, 28 October 2011

What is the difference between ++var and var++?

The ++ operator is called the increment operator. When the operator is placed before the variable (++var), the variable is incremented by 1 before it is used in the expression. When the operator is placed after the
variable (var++), the expression is evaluated, and then the variable is incremented by 1. The same holds true for the decrement operator (--). When the operator is placed before the variable, you are said to