How to convert a positive number to negative in C

1 Answer

0 votes
#include <stdio.h>
 
int main(void) {
    int x = 9472;
     
    printf("%i\n", x);
 
    x = x * -1;   
     
    printf("%i\n", x);
     
    return 0;
}
 
 
 
 
 
/*
run:
 
9472
-9472
 
*/

 



answered May 8, 2022 by avibootz
edited May 9, 2022 by avibootz

Related questions

1 answer 141 views
1 answer 121 views
1 answer 343 views
1 answer 130 views
1 answer 130 views
1 answer 127 views
...