Task - Using pointers to process arrays (C Languaage)
In a TV show, each minute can be either interesting or boring. Assume that if 7 consecutive minutes are boring, then an average viewer will stop watching the show. Write a C program that calculates how many minutes that an average viewer will watch a TV show, given the interesting minutes. Assume the TV shows are 45 minutes long.
Requirements
- Name your program project4_minutes.c.
- Follow the format of the examples below.
- The program will read in the number of interesting minutes, then read in the interesting minutes.
- The program should include the following function. Do not modify the function prototype.
int find_minute(int *minutes, int n);
-
- minutes represents the input array for interesting minutes, n is the length of the array (the number of interesting minutes). The function returns the how many minutes an average viewer will watch the show.
- This function should use pointer arithmetic– not subscripting – to visit array elements. In other words, eliminate the loop index variables and all use of the [] operator in the function.
- In the main function, call the find_minute function and display the result.
- Pointer arithmetic is NOT required in the main function.
Examples (your program must follow this format precisely)
Example #1
Enter the number of interesting minutes: 3
Enter the interesting minutes: 7 13 28
Output: 20
Note: In the first example, minutes 14, 15, 16, 17, 18, 19, 20 are all boring and thus an average viewer will stop watching after the 20th minute. So, the average viewer will watch for 20 minutes.
Example #2
Enter the number of interesting minutes: 3
Enter the interesting minutes: 7 13 18
Output: 25
Note: In the second example, minutes 19, 20, 21, 22, 23, 24, 25 are all boring and thus an average viewer will stop watching after the 25th minute. So, the average viewer will watch for 25 minutes.
Example #3
Enter the number of interesting minutes: 6
Enter the interesting minutes: 9 13 28 32 38 42
Output: 7
Note: In the third example, minutes 1, 2, 3, 4, 5, 6, 7 are all boring and thus an average viewer will stop watching after the 7th minute. So, the average viewer will watch for 7 minutes.
Example #4
Enter the number of interesting minutes: 6
Enter the interesting minutes: 5 12 18 24 31 38
Output: 45
Note: In the fourth example, there are no consecutive 7 boring minutes So, the average viewer will watch for the whole 45 minutes.
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 5 images
- In the C programming language, a pointer is used to store the ADDRESS of a data value. True Falsearrow_forwardYou can Use C++ programming, Windows Programming, Java, or Ptyhon to solve it The following table contains quarterly sales figures for five (5) departments: Quarter 1 Quarter 2 Quarter 3 Quarter 4 Total Department 1 750 660 910 800 Department 2 800 700 950 900 Department 3 700 600 750 600 Department 4 850 800 1000 950 Department 5 900 800 960 980 Total Design and write a Windows program/module named SalesAnalysis that will: Declare a two-dimensional integer array named sales – (Note: you have 6 rows and 5 columns) - that will hold the 4 quarterly sales for 5 departments Populate the first four columns for the 5 departments using the data in the preceding table. Contain a loop to compute and populate the total column. Store each department’s total in the array as it is being computed. Contain a loop to compute and populate the total row. Store each quarter’s total in the array as it is…arrow_forwardThis is warning you, don't use any AI platform to generate answer.arrow_forward
- Consider the following program specification: Write a program that will prompt the user for 10 integer values and stores them in an array. The values entered by the user only be between 0 and 100 and the program should validate these appropriately. The program should then: Display the average of the values Display the highest value in the array Display the lowest value in the array Discuss how the values should be validated. What control structures could be used? Using eclipsearrow_forwardA pointer variable is O the same thing as an array subscript dereferences a pointer and allows access to the value of the variable the pointer points to an operator that returns the memory address of a variable a variable that holds an addressarrow_forwardYou can use any C# compiler or the method you already know. The following table contains quarterly sales figures for five (5) departments: Quarter 1 Quarter 2 Quarter 3 Quarter 4 Total Department 1 750 660 910 800 Department 2 800 700 950 900 Department 3 700 600 750 600 Department 4 850 800 1000 950 Department 5 900 800 960 980 Total Design and write a Windows program/module named SalesAnalysis that will: Declare a two-dimensional integer array named sales – (Note: you have 6 rows and 5 columns) - that will hold the 4 quarterly sales for 5 departments Populate the first four columns for the 5 departments using the data in the preceding table. Contain a loop to compute and populate the total column. Store each department’s total in the array as it is being computed. Contain a loop to compute and populate the total row. Store each quarter’s total in the array as it is being computed.…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education