Write a Program using nested ifs in c#.
Write a Program using nested ifs in which the user is asked:
code:
using System;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
DateTime dt = DateTime.Now;
Console.WriteLine("{0}", dt);
Console.WriteLine("user wants to play the game /n Guess (yes or no)");
string playgame = Convert.ToString(Console.ReadLine());
if (playgame == "yes")
{
Console.WriteLine("Enter Your Age:");
int age = Convert.ToInt32(Console.ReadLine());
if (age < 5)
{
Console.WriteLine("You are too young to play.");
}
else
{
Console.WriteLine("Enter any number:");
int usernumber = int.Parse(Console.ReadLine());
int secretnumber =123;
if (usernumber==secretnumber)
{
Console.WriteLine("You have successfully guessed the secret number ");
}
else
{
Console.WriteLine("“You are not successfully guessed the secret number; ");
}
}
}
else
{
Console.WriteLine("Maybe next time");
}
}
}
}
very thank you bro
ReplyDelete