[SOLVED] COM1002 LAB 2

30.00 $

Category:

Description

Rate this product

Write a C program that computes the maximum, minimum, sum and average of 3 integers. This program reads 3 integers and a character that specifies the math opera9on (x for maximum, m for minimum, s for sum, a for average) from command prompt and prints the result of the opera9on. The input/output format is provided below.

The output should be printed in integer format for x, m and s opera9ons; but in floa-ng point format for average (a) opera9on. Floa9ng points must be printed in 2 digits precision aDer the decimal point (See Hint below).

Input: <number 1>[space] <number 2>[space] <number 3>[space] <operaQon>

Output: <computed value>

Example 1:

>15 3 28 m >3

Example 2:

>20 32 4 s

>56

Example 3:

>20 32 4 a

>18.67

Hint: %.2f format specifier prints 2 digit precision for floa9ng point numbers.

Warning: Your source codes will be scanned by a program for chea9ng. Any form of chea9ng is forbidden. Please write your own source codes and submit that!