IN C LANGUAGE
This program initially reads two integers from standard input: (1) an integer T and (2) a positive integer N. It then reads N integers and counts the numbers that are greater than T and the numbers than are less than T. It then prints out these two counts.
Example
What is the threshold value? 7 How many values? 5 Enter 5 values: 6 7 9 9 8 3 values are greater than 7 1 values are less than 7
Notes
#include <stdio.h> int main() { int threshold, i, n, greater = 0, less = 0, num; printf("What is the threshold value?\n"); scanf("%d", &threshold); printf("How many values?\n"); scanf("%d", &n); printf("Enter %d values:\n", n); for (i = 0; i < n; ++i) { scanf("%d", &num); if (num < threshold) less++; if (num > threshold) greater++; } printf("%d values are greater than %d\n", greater, threshold); printf("%d values are less than %d\n", less, threshold); return 0; }
Get Answers For Free
Most questions answered within 1 hours.