// 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
-
transpose of the given matrix #include<stdio.h> #include<conio.h> main() { int a[5][5],b[5][5],m,n,i,j; clrscr(); p...
-
multiply two given matrix #include<stdio.h> #include<conio.h> main() { int a[5][5],b[5][5],c[5][5],m,n,p,q,i,j,k; clrsc...
-
Assemblies In the applications that you build within the .NET Framework, assemblies will always play an important role. Assemblies can be th...
-
main() { int n,i,j,k,temp; int a[10]; clrscr(); printf("\n Enter number of elements:"); scanf("%d",&n); for(i=0;i...
-
In anticipation of this future, Microsoft has developed the .NET Framework and the tools necessary to build in this new environment. Microso...
No comments:
Post a Comment