//frequecy of a number in an array
#include<stdio.h>
int main()
{
int r[]={1,2,3,4,6,1,3,4,6,7,6,8,6}; int n,i,count=0; printf("enter the number"); scanf("%d",&n);
for(i=0;i<=12;i++);
if(r[i]==n) count++;
}
printf(“the frequency of the number %d is %d”,n,count);
return 0;
Remove the semicolon after the for loop i.e. for(i=0;i<=12;i++)
If possible please share problem link also
You have a semi-colon “;” at the end of the for loop line. This is preventing the loop from starting and hence the wrong answer.
This line is the issue. Your for loop is being terminated by the semicolon (;) and the compiler isn’t accessing the code inside it, leading to a wrong answer/error