How to convert a positive number to negative in C++

1 Answer

0 votes
#include <iostream>

int main() {
    int x = 3736;
    
    std::cout << x << "\n";
    
    x = x * -1;   
    
    std::cout << x << "\n";
}



 
/*
run:
 
3736
-3736
 
*/

 



answered May 9, 2022 by avibootz
...