Read 10 integers from the keyboard in the range 0 -100, and count how many of them are larger than 50, and display this result.
#include <stdio.h>
int main()
{
int arr[10] = {};
int quantity_more50 = 0;
for (int i = 0; i != 10; ++i)
{
printf( "Enter a value, range 0 - 100: ");
scanf("%d", &arr[i]);
}
for(int i = 0; i!= 10; ++i)
{
if(arr[i] > 50)
{
printf("%d\t", arr[i]);
quantity_more50 += 1;
}
}
printf("\nThe quantity is %d \n", quantity_more50);
return 0;
}
Comments
Leave a comment