1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
oee [108]
4 years ago
9

Write a C program to perform simple C arithmetic calculations. The user is to enter a simple expression (integer operator intege

r) such as
15 + 30
The program is to extract the 2 operands and the operator, perform the indicated calculation and display the result. For example
15 + 30 = 45
Operators should include + , - , * , / , and %
Operands are positive integers , no sign
Use getchar to input the expression
Allow for variable spacing before the first operands and between operators and operands ( 0, 1, or more spaces)

Allow the user the option of entering another expression
Code a function for each operator to do the appropriate arithmetic operations (5 functions)
No global variables
No string handling functions
No arrays
May only use input and output functions such as getchar and putchar
Computers and Technology
1 answer:
Ilya [14]4 years ago
8 0

Answer:

Input example:

select the funcion: 1                                                                                                                  

write the 1sd number2                                                                                                                  

write the 2nd number1                                                                                                                  

value is 2.000000                                                                                                                      

Explanation:

#include <stdio.h>

main()

{

//define the variables as float

float a, b, c, e;

char d;

while (1)  

{      

//input values

printf("select the function: ");

scanf("%c",&d);

printf("write the 1sd number");

scanf("%f",&a);

getchar();

printf("write the 2nd number");

scanf("%f",&b);

getchar();

if (d=='%')

{

    a=a*b/100;

}

if (d=='*')

{

    a=a*b;

}

if (d=='+')

{

    a=a+b;

}

if (d=='/')

{

    a=a/b;

}

if (d=='-')

{

    a=a-b;

}

printf("value is %f \n",a);

}

printf("final value is %f",a);

getchar();

}

You might be interested in
What font is the declaration of independence?
Keith_Richards [23]
I believe it is old English text
4 0
4 years ago
What is co-operating process
Greeley [361]

Answer: A process is independent if it cannot affect other process or be affected by it

Explanation:

3 0
4 years ago
Types of network model​
dexar [7]

Answer:

OSI Model and TCP/IP Model

Explanation:

4 0
3 years ago
Attention merchants define
Marina CMI [18]

Answer:

A merchant is a person who buys or sells goods in large quantities, especially one who imports and exports them.

4 0
3 years ago
PLEASE HELP. I NEED ASAP!!
Katena32 [7]
D. consider how long you plan to keep your money in the investment.
7 0
3 years ago
Read 2 more answers
Other questions:
  • Which is better to use for cleaning electronics, Ethyl alcohol vs isopropyl alcohol?
    14·1 answer
  • What are the differences between message confidentiality and message integrity? Can you have confidentiality without integrity?
    9·1 answer
  • Which of these consoles have 64 bit architecture
    13·1 answer
  • A) A cable that is mainly used in the cable television network
    11·1 answer
  • Write a SELECT statement that selects all of the columns for the catalog view that returns information about foreign keys. How m
    6·1 answer
  • The spreadsheet below shows the age, grade level, major, and minor of four students in college. A purple background in the
    5·1 answer
  • Greedy Algorithm Design
    8·1 answer
  • PLEASE ANSWER
    6·1 answer
  • Kate saves her work on a secondary storage device that is fairly new, and uses flash technology instead of disks.
    10·1 answer
  • Name a wireless technology tat may work with one device and not another?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!