Concept of Arithmatic Operator in C#
using System;
class Operators
{
public static void Main(String[] args)
{
int a,b,c,d;
Console.WriteLine("ARITHMATIC OPERATION\n");
do{
Console.WriteLine("Enter 1st no for arithmatic operation\n");
a=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter 2nd no for arithmatic operation\n");
b=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Choose from the following for operation:\n");
Console.WriteLine("1.+\t2.-\n3.*\t4.%\n");
c=Convert.ToChar(Console.ReadLine());
switch(c)
{
case '1':d=a+b;
Console.WriteLine("Sum is:{0}",d);
break;
case '2':d=a-b;
Console.WriteLine("difference is:{0}",d);
break;
case '3':d=a*b;
Console.WriteLine("product is:{0}",d);
break;
case '4':d=a%b;
Console.WriteLine("remainder is:{0}",d);
break;
}
}while(c!=5);
Console.ReadLine();
}
}
class Operators
{
public static void Main(String[] args)
{
int a,b,c,d;
Console.WriteLine("ARITHMATIC OPERATION\n");
do{
Console.WriteLine("Enter 1st no for arithmatic operation\n");
a=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter 2nd no for arithmatic operation\n");
b=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Choose from the following for operation:\n");
Console.WriteLine("1.+\t2.-\n3.*\t4.%\n");
c=Convert.ToChar(Console.ReadLine());
switch(c)
{
case '1':d=a+b;
Console.WriteLine("Sum is:{0}",d);
break;
case '2':d=a-b;
Console.WriteLine("difference is:{0}",d);
break;
case '3':d=a*b;
Console.WriteLine("product is:{0}",d);
break;
case '4':d=a%b;
Console.WriteLine("remainder is:{0}",d);
break;
}
}while(c!=5);
Console.ReadLine();
}
}
output:
No comments:
Post a Comment