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

Related questions

1 answer 150 views
1 answer 130 views
1 answer 130 views
1 answer 127 views
1 answer 154 views
1 answer 129 views
...