write a c program to find mode using for loop
Answers
Answered by
0
Answer:
Algorithm
We can derive an algorithm to find mode, as given below −
START
Step 1 → Take an integer set A of n values
Step 2 → Count the occurence of each integer value in A
Step 3 → Display the value with highest occurence
STOP
Pseudocode
We can now derive pseudocode using the above algorithm, as follows −
procedure mode()
Array A
FOR EACH value i in A DO
Set Count to 0
FOR j FROM 0 to i DO
IF A[i] = A[j]
Increment Count
END IF
END FOR
IF Count > MaxCount
MaxCount = Count
Value = A[i]
END IF
END FOR
DISPLAY Value as M
Similar questions