Languge C Code
Write a program that acts as an integer calculator that supports a single arithmetic operation at a time. The user should enter the calculation on a single line. The program should continuously accept new inputs before until the user submits a blank line (return). The program should support all of the following operations: +, -, *, /, % (modulo). It should not be necessary to use the math.h library. Your program should not produce any output except for the answers to provided expressions.
#include<stdio.h>
#include<stdlib.h>
int main()
{
int opt,a,b,result;
while(1)
{
printf("1.addition\n2.subtract\n3.multiplication\n4.divison\n5.modulo
divison\nexit\n");
printf("enter your option ");
scanf("%d",&opt);
if(opt==1)
{
printf("enter
1st value ");
scanf("%d",&a);
printf("enter
2nd value ");
scanf("%d",&b);
result=a+b;
printf("the
addition of %d and %d=%d\n",a,b,result);
}
else if(opt==2)
{
printf("enter
1st value ");
scanf("%d",&a);
printf("enter
2nd value ");
scanf("%d",&b);
result=a-b;
printf("the
subtraction of %d and %d=%d\n",a,b,result);
}
else if(opt==3)
{
printf("enter 1st value ");
scanf("%d",&a);
printf("enter
2nd value ");
scanf("%d",&b);
result=a*b;
printf("the
multiplication of %d and %d=%d\n",a,b,result);
}
else if(opt==4)
{
printf("enter
1st value ");
scanf("%d",&a);
printf("enter
2nd value ");
scanf("%d",&b);
result=a/b;
printf("the
divison of %d and %d=%d\n",a,b,result);
}
else if(opt==5)
{
printf("enter
1st value ");
scanf("%d",&a);
printf("enter
2nd value ");
scanf("%d",&b);
result=a%b;
printf("the
divison of %d and %d=%d\n",a,b,result);
}
else
{
exit(0);
}
}
}
Languge C Code Write a program that acts as an integer calculator that supports a single...
Design a calculator program that will add, subtract, multiply, or divide two numbers input by a user.Your program should contain the following:-The main menu of your program is to continue to prompt the user for an arithmetic choice until the user enters a sentinel value to quit the calculatorprogram.-When the user chooses an arithmetic operation (i.e. addition) the operation is to continue to be performed (i.e. prompting the user for each number, displayingthe result, prompting the user to add two...
1. Specification Write a C program to implement a simple calculator that accepts input in the following format and displays the result of the computation: calc [operand_1] [operator] [operand_2] The operands operand_1 and operand_2 are non-negative integers. The operator is one of the following: addition (+), subtraction (-), multiplication (x), division (/) and modulo (%). Note: For the multiplication operator, use letter ‘x’. If you use the asterisk ‘*’, your program will not work properly 2. Implementation • The program...
(PYTHON) Write a program that displays the following menu:. , Write Algorithm for Code Geometry Calculator 1. Calculate the Area of a Circle 2. Calculate the Area of a Rectangle 3. Calculate the Area of a Triangle 4. Quit Enter your choice (1 - 4): If the user enters 1, the program should ask for the radius of the circle and then display its area. If the user enters 2, the program should ask for the length and width of...
Write a C program named space_to_line.c that features a while loop that continuously reads input from the user one character at a time and then prints that character out. The exception is that if the user inputs a space character (‘ ‘), then a newline character (‘\n’) should be printed instead. This will format the output such that every word the user inputs is on its own line. Other than changing the spaces to newlines, the output should exactly match...
C++ programming For this assignment, write a program that will act as a geometry calculator. The program will be menu-driven and should continue to execute as long as the user wants to continue. Basic Program Logic The program should start by displaying a menu similar to the following: Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice(1-3): and get the user's choice as an integer. After the choice...
this is a C++ program! You will write a program that performs the following tasks for a simple mathematical calculator: (1) Open a user-specified file for input. Prompt for the name of the file, read it into a string variable, echo print it to the terminal and then open it. If the file is not opened, enter into a loop that prints out an error message, resets the input file stream variable (see the hints section), obtains a new file...
Your task is to write a C++ program that consumes integer values as command line arguments and returns the arithmetic mean of these values. To increase the flexibility of the program, there should be no set number of arguments. To overcome this, we will require the argument argv[1] to be the number of integers the user enters. For example, if the user wants to calculate the arithmetic mean of 4 numbers, they would pass in 4 as the first argument...
Write a Java program which allows the user to perform simple tasks on a calculator. A series of methods allows the user to select an operation to perform and then enter operands. The first method displays a menu, giving the user the choice of typing in any one of the following: +, -, *, /, or % representing the usual arithmetic operators (Each operation should be done on numbers negative(-) to positive(+), positive(+) to negative(-), negative(-) to negative(-), and positive(+)...
ENGR 40 PROGRAMMING ASSIGNMENT MENU-DRIVEN CALCULATOR PROGRAM Use a switch statement to build a menu-driven calculator. Your program should ask the user to choose from a list of ten possible functions (square root, square, natural log, common log, e'x yx, 1/x, sin(x), cos(x), and tan(x). Each choice will correspond to an integer -example: (1) square root, (2) square, etec. Once the person has input a function choice then a switch statement will control the flow of the program- ie. the program...
Your program must evaluate algebraic expressions over real numbers in Reverse Polish Notation (RPN). + (addition), - (subtraction), * (multiplication) and / (division) should be treated as arithmetic operations. Depending on the selection, numerical values must be entered and displayed in decimal, hexadecimal or binary form. Example: The expression ((3+4) *(7+1.6-12) -5) / (3-8.7)Will be calculated on your RPN calculator as 3 4 + 7 1.6 + 12 - * 5 - 3 8.7 - / Your RPN computer's user...