I am having trouble doing this problem. It is:
"write a program that asks the user to enter a list of integers. The program will then determine the largest value and the number of times it was entered.
-the user will first enter how many numbers the list contains.
-use a for loop to find the maximum value and the number of times it was entered"
This is what I have done. I cant seem to figure out how to count how many times the maximum value has been entered.
Code:#include <stdio.h>
#include <limits.h>
int main()
{
int num, num2, max;
int counter;
int counter2=0;
max = INT_MIN;
printf ("Enter the number of elements in this list: ");
scanf("%d",&num);
printf ("Enter the elements in this list: \n");
for(counter=1;counter<=num;counter++)
{
scanf ("%d",&num2);
if(num2=num2)
{
counter2++;
}
if(num2>max)
{
max = num2;
}
}
printf ("\nThe maximum number is %d and it was entered %d times\n",max, counter2);
return 0;
}