Hello Guys! Welcome To My Blog!
YES OR NO PROGRAM IN C#
Today we will be learn how to make yes or no program
in this code we only used if else Condition it is very Simple
using System;
namespace yes_or_no
{
class Program
{
static void Main(string[] args)
{
string user;
while (true)
{
Console.WriteLine("Enter yes to continue program if you want to break type no");
user = Console.ReadLine();
if (user == "yes")//if user type yes program will be run again
{
}
else if (user == "no")
{
break;//if user type no program will be break
}
else { Console.WriteLine("Type Only yes Or no"); }//if user type something other than yes or no,it willgive you hint
}
}
}
}
OUTPUT!
Enter yes to continue program if you want to break type no
yes
Enter yes to continue program if you want to break type no
yes
Enter yes to continue program if you want to break type no
mm
Type Only yes Or no
Enter yes to continue program if you want to break type no
no
Comments
Post a Comment