if
(condition)
{
Statements
.
.
.
}
Example:-
if statement will
evaluate the condition. If it is true, it will execute the statements that
follow it. Otherwise, it will leave the block of statements that are followed
by it
Example:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CABasics
{
class IFExample6
{
static
void Main(string[]
args)
{
int
N;
Console.WriteLine("Enter any Number either 1 or 2");
N=Convert.ToInt32(Console.ReadLine());
if
(N == 1)
{
Console.WriteLine("Hai");
}
if (N
== 2)
{
Console.WriteLine("Hellow");
}
Console.ReadLine();
}
}
}
|
No comments:
Post a Comment