I have to create a program in which I must write a program that looks something like this:
EXAMPLES:
Enter 10 digits: 4 4 4 4 4 4 4 4 4 4
All values are equal
PROGRAM ENDS
Enter 10 digits: 9 9 9 9 9 9 9 9 8 8
Min= 8
Max= 9
Min_count= 2
Max_count= 8
Between_count= 0
PROGRAM ENDS
DIRECTIONS: Write a program which will prompt the user to enter 10 valid C int values each >= 0. Compute the minimum of the 10 values. Compute the maximum of the 10 values. If min = max, print the message "All values are equal" then print the usual PROGRAM ENDS line, and terminate the program. Otherwise, display the minimum value. Display the maximum value. Display the number of elements equal to the minimum. Display the number of elements equal to the maximum. Display the number of elements with values between min and max (i.e. display the number of elements greater than minimum and less than the maximum). Then, print the PROGRAM ENDS line and terminate the program. Ensure that your program concludes by displaying "PROGRAM ENDS" followed by a single newline character.
So far this is what I have created:
"pe4.c" 77 lines, 924 characters
1 #include <stdio.h>
2
3 int main ( )
4
5 {
6 int i, a[10], max;
7 printf ("enter 10 digits ./n");
8 for (i=0; i<10;i++){
9 scanf ("%d",&a[i]);}
10 max = (max, [
11
12 int maximum ( ){
13
14
15 int max = a[0];
16 for(i=0; i<10; i++)
17 {
18 if (a[i] > max)
19 {
20 max = a[i];
21 }
22 }
23 return max;
24 }
25
26
27 int minimum ( )
28 {
29 int min = a[0];
30
31 for(i=0; i<10; i++)
32 if (a[i] < min)
33 {
34 min = a[i]
35 }
36 return min;
37 }
38 int max_count ()
39 {
40 int i, max, current_max, current, numbers;
41 int count = 0;
42 for (i = 0; i < numbers; i++)
43 {
44 scanf("%d", ¤t);
45 if (current_max > current)
46 {
47 max = current_max;
48 count = 1;
49 if (current == current_max)
50 count++;
51 }
52 }
53
54 }
55
56 int min_count ()
57 {
58 int i, min, current_min, current, numbers;
59 int count = 0;
60 for (i = 0; i < numbers; i++)
61 {
62 scanf("%d", ¤t);
63 if (current_min < current)
64 {
65 min = current_min;
66 count = 1;
67 if (current == current_min)
68 count++;
69 }
70 }
71 }
72 {
73 printf ("Numbers between min and max")
74
75 printf ("PROGRAM ENDS");
76 }
77 printf ("PROGRAM ENDS");
Can anyone please help me out with creating the number of elements with values between min and max?
Thank you!


Sign In
Create Account

Back to top









