Write a program that asks the user to enter an integer, then gets the input from the user. The program should repeatedly ask the user to enter an integer until the user enters an integer greater than 10; then it should print "Integer greater than 10 detected!" and should end. The program must contain only two Write or WriteLine statements!
Solution:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DoWhile
{
class Program
{
static void Main(string[] args)
{
int value = 0;
do
{
Console.WriteLine("Enter an Integer");
string text = Console.ReadLine();
Int32.TryParse(text, out value);
}
while (value <= 10);
Console.WriteLine("Integer greater than 10 detected!");
Console.ReadLine();
}
}
}
No comments:
Post a Comment