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
...