Practical : 2
Subject : .Net
Subject : .Net
Aim : C# program to perform different operations like Addition, Subtraction, Multiplication, Division.
Source Code :
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
namespace
pr008
{
class Class2
{
static void Main(string[] ar)
{
string y;
do
{
Console.Write("Enter a :
");
int a =
Convert.ToInt32(Console.ReadLine());
Console.Write("Enter b :
");
int b =
Convert.ToInt32(Console.ReadLine());
Console.WriteLine("1)
addition 2) substraction 3) division 4) multipication 5) module ");
Console.Write("Enter
Choice : ");
int i =
Convert.ToInt32(Console.ReadLine());
switch (i)
{
case 1:
int c = a + b;
Console.WriteLine("c : " + c);
break;
case 2:
c = a - b;
Console.WriteLine("c : " + c);
break;
case 3:
c = a / b;
Console.WriteLine("c : " + c);
break;
case 4:
c = a * b;
Console.WriteLine("c : " + c);
break;
case 5:
c = a % b;
Console.WriteLine("c : " + c);
break;
}
Console.Write("Do You Want
to Continue (Y/N)? : ");
y = Console.ReadLine();
} while (y == "Y" || y ==
"y");
Console.Read();
}
}
}
Output :
0 comments:
Post a Comment