I'm new to this so sorry if this question already have been answered.
I am writing a program in c# and I'm trying to make an if-statement where an integer cannot be higher than 10 raised to 9 (10^9) and not below or equivalent to 0. I tried to search for it and found that I perhaps can use the Math.Pow(10,9) but I don't see how I can do that in the if-statement? Now I have only tried to compile the code while writing a big number, but it's supposed to be 10 raised to 9 and I don't know how to write it?
Here's the code:
if (C > 100000 || C <= 0)
You can use the following code to validate if a number is between 10^9 and 0
if (Math.Pow(10, 9) >= C && C > 0)
Console.WriteLine("valid");
else
Console.WriteLine("Invalid");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.