0

write a Programme to enter a number to check it is even or not using simple if

11th Aug 2016, 4:05 PM
A.r. Kumar Kishan
A.r. Kumar Kishan - avatar
5 ответов
+ 1
int x = Convert.ToInt32(Console.WriteLine()); If(x % 2 == 0) { Console.WriteLine(x + " is even"); } else { Console.WriteLine(x + " us uneven"); }
11th Aug 2016, 4:14 PM
Andreas BeEm Kvist
Andreas BeEm Kvist - avatar
+ 1
@Andreas has made a mistake: the right int x=Convert.ToInt32(Console.ReadLine()); instead of WriteLine
11th Aug 2016, 8:24 PM
Marco Romanin
Marco Romanin - avatar
+ 1
@cacao Thank you :p Without a compiler checking errors, these things are easy to mess up.
11th Aug 2016, 8:34 PM
Andreas BeEm Kvist
Andreas BeEm Kvist - avatar
+ 1
@Andreas Yep :P too easy to mess up these little bastards
11th Aug 2016, 8:51 PM
Marco Romanin
Marco Romanin - avatar
+ 1
int a = ConvertToInt32(Console.ReadLine()); if (a%2 ==0){ Console.WriteLine("the number {0} is even!", a); } else { Console.WriteLine("the number {0} is not even!", a); }
21st Aug 2016, 2:30 PM
avy7352
avy7352 - avatar