1,184 views
0 0 votes
main()
{
    int i=-1;
    -i;
    printf("i = %d, -i = %d \n",i,-i);
}

1 Answer

Best answer
4 4 votes
main()
{
    int i=-1; // This will store -1 in i
    
    -i;  // This will not have any effect on i as you are not asigning that in i
    
    printf("i = %d, -i = %d \n",i,-i); // First will print value of i which is -1
                                       // Second will print value of -i which is 1
}

Hence the output will be -1 1

• selected by
Position:
Show:

Related questions

0 0 votes
1 answers 1 answer
1.5k
1.5k views
Desert_Warrior asked May 16, 2016
1,531 views
main() { int c=- -2; printf("c=%d",c); }
0 0 votes
2 answers 2 answers
2.2k
2.2k views
Desert_Warrior asked May 16, 2016
2,231 views
void main() { unsigned giveit=-1; int gotit; printf("%u ",++giveit); printf("%u \n",gotit= giveit); }
0 0 votes
1 answers 1 answer
1.3k
1.3k views
stblue asked Oct 18, 2017
1,322 views
#include <stdio.h>int main(){ int a[] = {50, 60, 10, 30, 40, 20 }; int *b[] = {a+3, a+4, a, a+2, a+1, a+5 }; int c = b; c++; printf("%u, %u, %u\n", c-b, *...
1 1 vote
1 answers 1 answer
2.9k
2.9k views
Desert_Warrior asked May 16, 2016
2,907 views
#include<stdio.h void foo(char *); int main() { char *string = "Hello"; foo(string); printf("%s",string); return 0; } void foo(char *a) { while(*a) { *a += 1; a++; } }(a)...