-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintegers1.c
More file actions
42 lines (36 loc) · 951 Bytes
/
integers1.c
File metadata and controls
42 lines (36 loc) · 951 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdio.h>
/*
TODO:
Write a program that takes 3 integers from the user, then prints the
*sum
*average
*product
*smallest
*largest
*/
int main(void){
int num1, num2, num3, sum, product, smallest, largest;
float average;
printf("%s", "Enter 3 different integers: ");
scanf("%d%d%d", &num1, &num2, &num3);
sum = num1 + num2 + num3;
average = (float) sum / 3;
product = num1 * num2 * num3;
smallest = num1;
if(num2 < smallest) {
smallest = num2;
}
if(num3 < smallest){
smallest = num3;
}
largest = num1;
if(num2 > largest){
largest = num2;
}
if(num3 > largest){
largest = num3;
}
printf("%s%d%s%f%s%d%s%d%s%d%s", "The sum is: ", sum, "\nThe Average is: ", average, "\nThe product is: ", product,
"\nThe smallest is: ", smallest, "\nThe largest is: ", largest, "\n");
return 0;
}