Friday, May 21, 2010

C language: A prog that searches a number & display number of times it occurs on the last of 12 input value?

after entering elements to the array a[12] use follwoing code








for(i=1;i%26lt;12;i++)


{





if(ar[i]==num)


{


n++;


}








printf("Number=%d occurs %d times",num,n);


}





visit my blog


http://codesbyshariq.blogspot.com for more programs

C language: A prog that searches a number %26amp; display number of times it occurs on the last of 12 input value?
This is easily done using an array of 12 numbers. There is a running index of where the next number goes. A simple search can count the number of occurrences. There are more elegant ways to do this if one is dealing with a lot of data, but for twelve numbers one may as well keep it simple.


No comments:

Post a Comment