Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Arithmetic Operation Using Switch Case Statement In C#
WhatsApp
Vijayaragavan S
Aug 11
2016
33.6
k
0
1
using
System;
class
Program
{
static
void
Main()
{
//Reading First Number
Console.Write(
"Enter No1: "
);
int
a = Convert.ToInt16(Console.ReadLine());
//Reading Second Number
Console.Write(
"Enter No2: "
);
int
b = Convert.ToInt16(Console.ReadLine());
Console.WriteLine(
"1.Addition"
);
Console.WriteLine(
"2.Subtraction"
);
Console.WriteLine(
"3.Divsion"
);
Console.WriteLine(
"4.Multiplication"
);
Console.WriteLine(
"5.Increment"
);
Console.WriteLine(
"6.Decrement"
);
//Reading a Choice
int
c = Convert.ToInt16(Console.ReadLine());
switch
(c)
{
case
1:
Console.WriteLine(
"Addition Of Two Numbers : "
+(a+b));
break
;
case
2:
Console.WriteLine(
"Subtraction Of Two Numbers : "
+ (a - b));
break
;
case
3:
Console.WriteLine(
"Division Of Two Numbers : "
+ (a / b));
break
;
case
4:
Console.WriteLine(
"Multiplicaion Of Two Numbers : "
+ (a * b));
break
;
case
5:
Console.WriteLine(
"Increment Numbers : "
+ (++a) +
" "
+ (++b));
break
;
case
6:
Console.WriteLine(
"Decrement Numbers : "
+ (--a)+
" "
+(--b));
break
;
default
:
Console.WriteLine(
"Choose Only 1 To 6 "
);
break
;
}
Console.ReadLine();
}
}
Swicth case
C#
Arithmetic
Up Next
Arithmetic Operation Using Switch Case Statement In C#