1,006 views
0 votes
0 votes
 main()
{
    int c=- -2;
    printf("c=%d",c);
}

1 Answer

Best answer
7 votes
7 votes
main()
{
    int c=- -2; // Here -2 is a integer constant and second - is an unary operator
                // Hence C will get +2
                
    printf("c=%d",c); //2 will be printed here as c's value
}

Hence the output is c=2

selected by

Related questions

0 votes
0 votes
2 answers
1
Desert_Warrior asked May 16, 2016
1,309 views
void main() { unsigned giveit=-1; int gotit; printf("%u ",++giveit); printf("%u \n",gotit= giveit); }
0 votes
0 votes
1 answer
2
Desert_Warrior asked May 16, 2016
781 views
main() { int i=-1; -i; printf("i = %d, -i = %d \n",i,-i); }
0 votes
0 votes
1 answer
3
Desert_Warrior asked May 16, 2016
468 views
#include<stdio.h int main() { char str[] = {'a','b','c','\0'}; str[0] -= 32; printf("%s",str); return 0; }