// Storage
int value1 = 0;
int value2 = 0;
int total = 0;
string operation;
// Get first number
value1 = GetNumber();
// Get Operation
Console.Write("What operation would you like to perform: ");
operation = Console.ReadLine();
// Get second number
value2 = GetNumber();
// Perform the operation
if (operation == "+")
total = value1 + value2; // Addition
else if (operation == "-")
total = value1 - value2; // Subtraction
else if (operation == "/")
total = value1 / value2; // Division
else if (operation == "*")
total = value1 * value2; // Multiplication
else
{
// Ignore other keypresses
}
// Output the answer
Console.WriteLine("The total is {0}", total);
Subscribe to:
Post Comments (Atom)
Popular 5 Posts Last 7 days
-
main() { int n; clrscr(); printf("\n enter the number: "); scanf("%d",&n); fact(n); printf(...
-
.NET is a collection of tools, technologies, and languages that all work together in a framework to provide the solutions that are needed t...
-
-: Bubble Sort :- #include<stdio.h> #include<conio.h> main() { int i,j,n,a[10],temp; clrscr(); printf("\nEnter...
-
matrix with row-wise sum #include<stdio.h> #include<conio.h> main() { int a[5][5],m,n,i,j,sum[5]; clrscr(); printf(...
-
main() { int a[][4]={ 5,6,7,8, 1,2,3,4, 2,3,4,5 }; int *p; int (*q)[4]; // q is a point...
No comments:
Post a Comment