Question

In: Computer Science

make a calculator in C++ or C language that can take up to 5 values at...

make a calculator in C++ or C language that can take up to 5 values at same time

Solutions

Expert Solution

Answer:

#include <iostream>
using namespace std;

int main()
{
char op;
float num1, num2,num3,num4,num5;

cout << "Enter operator either + or - or * or /: ";
cin >> op;

cout << "Enter five operands: ";
cin >> num1 >> num2 >> num3 >> num4 >> num5;

switch(op)
{
case '+':
cout << num1+num2+num3+num4+num5;
break;

case '-':
cout << num1-num2-num3-num4-num5;
break;

case '*':
cout << num1*num2*num3*num4*num5;
break;

case '/':
cout << num1/num2/num3/num4/num5;
break;

default:
// If the operator is other than +, -, * or /, error message is shown
cout << "Error! operator is not correct";
break;
}

return 0;
}

Explanation:

First user type the operator and then operands. Here we use the switch statements where we given the different cases according to the operator.


Related Solutions

Please Use C language to Make a calculator. Make sure calculator is able to take up...
Please Use C language to Make a calculator. Make sure calculator is able to take up to 5 values. Try to make calculator using simple coding As you can. Please create a simple calculator with only +, -,* and divide. It has to be able to enter any numbers (including decimals) and be able to do the following functions: +, -, divide and multiply. Please have the answers, always rounded to two decimal figures. The calculator will also have to...
GPA calculator in C language To understand the value of records in a programming language, write...
GPA calculator in C language To understand the value of records in a programming language, write a small program in a C-based language that uses an array of structs that store student information, including name, age, GPA as a float, and grade level as a string (e.g., “freshmen,” etc.). Note:Code and Output Screenshots
"C language" Take this code and make the minor modification necessary to create a circular linked...
"C language" Take this code and make the minor modification necessary to create a circular linked list (Hint: Store a pointer to the first node in the next pointer of the last node.) Demonstrate that this is working by traversing the list until the first pointer is encountered 3 times. Next redefine the node structure to include a back pointer. This will enable your program to move from front to back and then from back to front. It is not...
The random variable X can take on the values -5, 0, and 5, and the random...
The random variable X can take on the values -5, 0, and 5, and the random variable Y can take on the values 20, 25, and 30. The joint probability distribution of X and Y is given in the following table: Y 20 25 30 X -5 0.15 0.02 0.06 0 0.08 0.05 0.05 5 0.32 0.10 0.17 a. Describe in words and notation the event that has probability 0.17 in the table. . b. Calculate the marginal distribution of...
What are the values that make up the 5-number summary? What types of value are they?
What are the values that make up the 5-number summary? What types of value are they?
IN C LANGUAGE 16.16 Lab 5: merge Name this program merge.c - This program will take...
IN C LANGUAGE 16.16 Lab 5: merge Name this program merge.c - This program will take two arguments from the command-line which will be the names of the two text files the program will read from. These text files contain a list of numbers each in ascending order. You'll open the text files and begin merging the two sets of numbers together until every unique number is printed to the screen once and in order. For example: file1.txt file2.txt 1...
C Programming Language Problem Title : Take Three Jojo just graduated and moved up to grade...
C Programming Language Problem Title : Take Three Jojo just graduated and moved up to grade 4. Today is his first day in 4th grade. Unfortunately, the lessons are held online because of the pandemic. So that the quality of learning remains good, Jojo's teacher gives a hard task for 4th grader. After the 4th graders finished their first task which is prime factorization. Jojo's teacher set up a game for the stundets. The game is very simple. Given N...
C++ language code plzzzzz As we know, here're bills with values: 1, 5, 10, 20, 50,...
C++ language code plzzzzz As we know, here're bills with values: 1, 5, 10, 20, 50, 100. Now, suppose you have enough amount for each kind of bill, when given a price, decide how many bills of each kind you should pay so that the total number of bills is minimized. Output the number of each bill you need to pay in the order 1, 5, 10, 20, 50, 100. SAMPLE INPUT 77 SAMPLE OUTPUT 2 1 0 1 1...
For C++ Make a function that swaps the values that change the values between the parameters...
For C++ Make a function that swaps the values that change the values between the parameters as the following rule. The functions swap takes 2, 3 or 4 parameters and these functions are implemented as the overloading functions. swap(int &, int &) : change the values each other. swap(int &, int &, int &) : change the value with the order. [min, medium, max] swap(int &, int &, int &, int &) : change the value like circular-shift-right [A, B,...
1-Look up the requested values using book tables. You may check with a calculator, but enter...
1-Look up the requested values using book tables. You may check with a calculator, but enter the table value.    Let T denote a t-distribution variable with 14 degrees of freedom. Find: P(T>1.761)=? Note: Enter X.XX AT LEAST ONE DIGIT BEFORE THE DECIMAL, TWO AFTER and round up. Thus, 27 is entered as 27.00, 3.5 is entered as 3.50, 0.3750 is entered as 0.38 2-Look up the requested values using book tables. You may check with a calculator, but enter...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT