
Write a program that inputs five different integers from the keyboard, then print the sum, the product, the smallest and the largest of these numbers. Use only single selection form of if statement. For example: 1 3 2 7 4 6 Sum is: 23 Average is: 4.5 Smallest: 1 Largest 7

#include <stdio.h>
#include <conio.h>
int main(void){
int num = 0;
int sum = 0;
int counter = 0;
int min=0;
int max=0;
int temp;
int product=1;
while(counter < 5){
printf("Enter number: ");
if(scanf("%d", &num) == 1){
if(num>=max){
max=num;
}
if(num<=temp){
min=num;
}
temp=num;
sum += num;
product*=num;
}
else{
fprintf(stderr, "Error!");
return 0;
}
counter++;
}
printf("Sum of numbers entered: %d\n", sum);
printf("Product of numbers entered: %d\n", product);
printf("The largest number is :%d\n",max);
printf("The smallest number is :%d",min);
return 0;
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.