Question
I have written a program that 10 integers (in the interval 1 to 10) and prints them on the screen. The program then asks the
I have written a program that 10 integers (in the interval 1 to 10) and prints them on the screen. The program then asks the user for a number and counts the number of occurrences of this specific number among the 10 randomized numbers and present the answer. The 10 numbers are saved in an array.
My question is: how can I modify the program to print the number that occurs the most frequently and the number that occurs least frequently among the 10 randomized numbers, along with the number of occurrences these numbers occurs with?
My code:
#include
int main() { int arr[SIZE]; int number, choice = 1; while (choice == 1) { CreateGenerator(arr); printf("What to search for: "); scanf_s("%d", &number); int occured = countElement(arr, SIZE, number); printf("The number %d occurs %d times ", number, occured); printf("Do you want to generate a new sequence (1 for yes, 0 for no)? "); scanf_s("%d", &choice); } return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started