Develop a flowchart and pseudocode for each programming question and include as
ID: 3891835 • Letter: D
Question
Develop a flowchart and pseudocode for each programming question and include as part of your submission.
Provide the source code in your submission with proper indentation, label use, commenting and layout for each programming question.
Thanks
Write a C program for an embedded application (using a dead/forever loop) which determines the maximum valued number in an array of numbers. Declare a global array with 10 elements of integer type, name it maxValueArray, and initialize the array to following values: -1, 5, 3, 8, -10, 23, 6, 5,2, 10. Declare a global integer type variable "arraySize" and initialize it to 10. Implement the functionality within the main() function. Once the task of determining the maximum number is completed, the main0 should stay in a forever loop.Explanation / Answer
pseudocode
procedure largest_array(maxValueArray)
Declare largest as integer
Set largest to 0
FOR EACH value in maxValueArray DO
IF maxValueArray[n] is greater than largest THEN
largest ? maxValueArray[n]
ENDIF
END FOR
Display largest
end procedure
C Code:
#include <stdio.h>
int main()
{
int maxValueArray[10]={-1,5,3,8,-10,23,6,5,2},arraySize=10, i, largest; // Declaring Variables
largest = maxValueArray[0];// Assign first value to largest variable
for (i = 9; i<10; i--) // Dead Loop
{
if (largest < maxValueArray[i]) // Find Outs the Largest Value In the Array
largest = maxValueArray[i];
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.