How to convert a positive number to negative in C#

1 Answer

0 votes
using System;
 
class Program
{
    static void Main() {
        int x = 847;
         
        Console.WriteLine(x);
         
        x = x * -1;
         
        Console.WriteLine(x);
    }
}
 
 
 
 
/*
run:
 
847
-847

*/

 



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