Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Take as an input an odd number and print the absolute value of it. If the number is even, print "Please write an odd number." and continue reading numbers.
- using System;
- namespace _11._Odd_Number
- {
- class OddNumber
- {
- static void Main(string[] args)
- {
- int n = Math.Abs(int.Parse(Console.ReadLine()));
- while (true)
- {
- if (n % 2 == 0 )
- {
- Console.WriteLine("Please write an odd number.");
- }
- else
- {
- Console.WriteLine($"The number is: {n}");
- break;
- }
- n = Math.Abs(int.Parse(Console.ReadLine()));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement