In: Computer Science
C program, please
Write a program that reads a sequence of 10 integer inputs and prints the smallest and largest of the inputs and the number of even and odd inputs.
for a beginner please, you could use a while loop,if-else,
#include <stdio.h> int main() { int i, evenCount = 0, oddCount = 0, min, max, n; printf("Enter number: "); scanf("%d",&n); min = n; max = n; if(n%2==0){ evenCount += 1; } else{ oddCount += 1; } i = 1; while(i<10){ printf("Enter number: "); scanf("%d",&n); if(min > n){ min = n; } if(max < n){ max = n; } if(n%2==0){ evenCount += 1; } else{ oddCount += 1; } i++; } printf("Smallest = %d\n",min); printf("Largest = %d\n",max); printf("Number of evens = %d\n",evenCount); printf("Number of odds = %d\n",oddCount); return 0; }