C# PROGRAM MANAGEMENT/ 1) condition management
C# PROGRAM MANAGEMENT:-
-there are two types of management
1) condition management
2) flow management
1) condition management:-
-if else statement
-else if statement
-switch case statement
2) flow management:-
-while loop
-do while loop
-for loop
-for each loop
1)CONDITION MANAGEMENT:-
IF ELSE STATEMENT:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IFELSESTATEMENT
{
class Program
{
static void Main(string[] args)
{
int age;
Console.WriteLine("Enter your age");
age = int.Parse(Console.ReadLine());
if (age>18)
{
Console.WriteLine("vote");
}
else
{
Console.WriteLine("not vote");
}
Console.ReadKey();
}
}
}
ELSE IF STATMENT:-
-it used to multiple condition.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ELSEIFSTATMENT
{
class Program
{
static void Main(string[] args)
{
int per;
Console.WriteLine("enter your percentage");
per = int.Parse(Console.ReadLine());
if (per>60)
{
Console.WriteLine("first division");
}
else if(per>50 && per<60)
{
Console.WriteLine("second division");
}
else if(per>40 && per<50)
{
Console.WriteLine("third division");
}
else
{
Console.WriteLine("fail");
}
Console.ReadKey();
}
}
}
SWITCH CASE STATMENT:- (option mei string lagega)
-this statement is used to option base programming.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SWITCHPROGRAM
{
class Program
{
static void Main(string[] args)
{
int ch;
Console.WriteLine("enter your choice");
ch = int.Parse(Console.ReadLine());
switch(ch)//switch only used choice variable
{
case 1: Console.WriteLine("one");
break;
case 2: Console.WriteLine("two");
break;
case 3: Console.WriteLine("three");
break;
default: Console.Write("invalid choice ");
break;
}
Console.ReadKey();
}
}
}
Comments
Post a Comment