In: Computer Science
Write an application named OddNums that displays all the odd numbers from 1 through 99. All ODD numbers should show all together(Should not need to scroll down), do it in 10 rows. FOR C#
C# code:
using System;
class OddNums{
static void Main(){
//looping from 1 to
99
for(int
i=1;i<=99;i++){
//checking if the number is odd
if(i%2!=0)
//printing the number
Console.Write(i+" ");
//checking to the row is filled
if(i%10==0)
//printing a newline
Console.WriteLine();
}
}
}
Screenshot:
Output: