Sunday, 5 January 2014

TO FIND HOW MANY TIMES AND AT WHAT INDEX THE GIVEN NUMBER OCCURED IN A ARRAY....!!!!

#include<stdio.h>
int main()
{
  int array[25]={1,2,4,3,1,6,8,9,5,3,1,4,6,9,7,3,1,5,7,8,0,3,2,5,0};
    int x,count=0,index[]={0},search;
    printf("Enter the number to be searched from above array:");
    scanf("%d",&search);
    for(x=0;x<25;x++)
    {
      
       if(array[x]==search)
       {
       count++;
       printf("Given number is found at the index:%d\n",x);
       }
    }
    if (count==0)
    printf("The Given number was not found");
    else
    printf("The Given number was found %d times\n",count);
    getch();
    return 0;
}
                

No comments:

Post a Comment