If statement in c#
using System;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please enter your lucky number");
int usernumber = Int32.Parse(Console.ReadLine());//Console.readline() return stringtype
if ((usernumber == 5) || (usernumber == 10)) //If this statement is true
{
//then-statement;
Console.WriteLine("You are lucky winner");
}
else
{
Console.WriteLine("!oops you lost a game");
}
Console.Read();
}
}
o/P
depends upon the user input.
using System;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please enter your lucky number");
int usernumber = Int32.Parse(Console.ReadLine());//Console.readline() return stringtype
if ((usernumber == 5) || (usernumber == 10)) //If this statement is true
{
//then-statement;
Console.WriteLine("You are lucky winner your won 100$");
}
else if ((usernumber ==15 ) ||(usernumber ==25 )) // || it a or symbol in electronic
//it means condition either satisfy (usernumber ==15 ) or (usernumber ==25 )
{
Console.WriteLine("You got a new change to enter your lucky number ");
}
else
{
Console.WriteLine("!oops you lost a game");
}
Console.Read();
}
}
using System;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please enter the number");
int usernumber = int.Parse(Console.ReadLine());
int number = usernumber / 5;
int digit = usernumber % 5;
bool xdigit=digit==0 ? true:false;
if (xdigit == true)
{
Console.WriteLine("!you won the game");
}
else
{
Console.WriteLine("!oops you lost a game");
}
Console.Read();
}
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please enter your lucky number");
int usernumber = Int32.Parse(Console.ReadLine());//Console.readline() return stringtype
if ((usernumber == 5) || (usernumber == 10)) //If this statement is true
{
//then-statement;
Console.WriteLine("You are lucky winner");
}
else
{
Console.WriteLine("!oops you lost a game");
}
Console.Read();
}
}
o/P
depends upon the user input.
using System;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please enter your lucky number");
int usernumber = Int32.Parse(Console.ReadLine());//Console.readline() return stringtype
if ((usernumber == 5) || (usernumber == 10)) //If this statement is true
{
//then-statement;
Console.WriteLine("You are lucky winner your won 100$");
}
else if ((usernumber ==15 ) ||(usernumber ==25 )) // || it a or symbol in electronic
//it means condition either satisfy (usernumber ==15 ) or (usernumber ==25 )
{
Console.WriteLine("You got a new change to enter your lucky number ");
}
else
{
Console.WriteLine("!oops you lost a game");
}
Console.Read();
}
}
using System;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please enter the number");
int usernumber = int.Parse(Console.ReadLine());
int number = usernumber / 5;
int digit = usernumber % 5;
bool xdigit=digit==0 ? true:false;
if (xdigit == true)
{
Console.WriteLine("!you won the game");
}
else
{
Console.WriteLine("!oops you lost a game");
}
Console.Read();
}
}
Comments