Reading 10 integers between 0-100 and counts how many of the are larger than 50 and displaying the result
#include <stdio.h>
int main() {
int count=0, x, n=0;
while (n<100) {
scanf("%d", &x);
if (x>=0 && x<=100) {
n++;
if (x > 50) {
count++;
}
}
}
printf("There were %d numbers greater than 50\n", count);
return 0;
}
Comments
Leave a comment