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
the first day anna read a quarter of the book. on the second day she read a third of the remainder. noticed that after two days
Misha Larkins [42]

Answer:

160 pages

Explanation:

Day\ 1 = \frac{1}{4}

Day\ 2 = \frac{1}{3}Remainder

Left = 80

Required

The number of pages

Let the number of pages be x.

So, on day 1; we have:

Day\ 1 = \frac{1}{4}x

After day 1, there are:\frac{3}{4}x left ----------------- i.e x - 1/4x

On day 2, we have:

Day\ 2 = \frac{1}{3} * \frac{3}{4}x

Day\ 2 = \frac{1}{4}x

At this point, we have:

Day\ 1 = \frac{1}{4}x

Day\ 2 = \frac{1}{4}x

Left = 80 ---- pages left

The summation of all must equal x, the book pages

Day\ 1 + Day\ 2 + Left = Total\\

\frac{1}{4}x + \frac{1}{4}x+ 80= x

Simplify the left-hand side

\frac{1}{2}x+ 80= x

Collect like terms

x - \frac{1}{2}x= 80

Simplify

\frac{2-1}{2}x= 80

\frac{1}{2}x= 80

Multiply by 2

2 * \frac{1}{2}x= 80*2

x = 160

4 0
3 years ago
There are many opportunities for unscrupulous people to break information system security. Of the five components in an informat
7nadin3 [17]

The answer is letter e.

People is the component poses the very large ongoing security risk. It also can be a threat to the safety. People play an essential part in most operational systems and methods. Information, ability and mental outlook often determine the feature and quantity of system output. Just as a stereo requires the right component, high-performance business systems require the right fit of people to work.


8 0
3 years ago
Read 2 more answers
Your ___________ is what you can see without the presence of an obstruction.
SCORPION-xisa [38]

Answer:

Line of sight

Explanation:

Your line of sight is the noticeable path of travel from your vehicle to your destination area. This line can be obstructed by a curve, a hill, high-forest wooded zones, large trucks, or other obstruction that prevents drivers from seeing the vehicle ahead. Therefore, if you cannot see around an obstruction, you should slow down and be willing to adjust your position until you can reestablish a clear line of sight to your path of travel and targeting area.

8 0
3 years ago
Some request lists might cause the disk scheduler to act the same when the three different algorithms are run. Create a request
storchak [24]

Answer:

35, 25, 50, 75, 95

Explanation:

List of five track numbers that will cause all three algorithms to visit the same tracks in the same order are -

35

25

50

75

95

Please go to attachment for the diagram how these 5 tracks will be traversed by various algorithms.

All the algorithms traverse in the order 35 -> 25 -> 50 -> 75 -> 95

7 0
3 years ago
Write a main function to do the following: Create a string that can hold up to 30 characters. Create an array of 10 strings with
masha68 [24]

Answer:

Check the explanation

Explanation:

#// do comment if any problem arises

//code

#include <stdio.h>

#include <ctype.h>

#include <string.h>

#include <stdlib.h>

void read(FILE *input, char array[10][61])

{

   // read all 10 strings

   for (int i = 0; i < 10; i++)

       fgets(array[i], 60, input);

}

void remove_newline(char array[10][61])

{

   for (int i = 0; i < 10; i++)

   {

       array[i][strlen(array[i]) - 1] = '\0';

   }

}

void smallest(char array[10][61])

{

   int s = 0;

   for (int i = 1; i < 10; i++)

   {

       if (strlen(array[s]) > strlen(array[i]))

           s = i;

   }

   printf("\nSmallest strnig: %s\n", array[s]);

}

void upper(char array[10][61])

{

   for (int i = 0; i < 10; i++)

   {

       int n = strlen(array[i]);

       for (int j = 0; j < n; j++)

       {

           array[i][j] = toupper(array[i][j]);

       }

   }

}

int main()

{

   char filename[30];

   // array of 10 strings

   char array[10][61];

   printf("Enter filename: ");

   gets(filename);

   // open file

   FILE *input = fopen(filename, "r");

   // read into array

   read(input, array);

   // close file

   fclose(input);

   // remove newline

   remove_newline(array);

   // print

   printf("Contents of file:\n");

   for (int i = 0; i < 10; i++)

       printf("%s\n", array[i]);

   // print smallest string

   smallest(array);

   // uppercase

   upper(array);

   // print again

   printf("\nContents of file after converting to uppercase:\n");

   for (int i = 0; i < 10; i++)

       printf("%s\n", array[i]);

}

kindly check the attached image below to see the Output:

6 0
3 years ago
Other questions:
  • Guidelines:
    6·1 answer
  • How to select the entire table in microsoft excel
    11·1 answer
  • The amount of vertical space between lines within paragraphs
    9·1 answer
  • When a crash results in property damages of any amount, the driver must notify:
    10·1 answer
  • You just installed a new application but users cannot connect to the application remotely. Which feature should be checked to en
    14·1 answer
  • In many DBMSs where no strict separation of levels is maintained, this one language is used by the DBA and database designers to
    13·1 answer
  • Write a C program to calculate and display the coordinates of midpoint - M of a linesegment between two given points - say A and
    7·1 answer
  • The rate of flow is called
    11·1 answer
  • Instructions
    15·1 answer
  • ICT Practical Work
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!