Tuesday, 18 February 2014

write a program to find number of occrance of character in a entered array


#include<stdio.h>
main()
{
char a[10];
char ch;
int i,count=0;
for(i=0;i<10;i++)
{
printf("enter the character in array a[%d]=",i);
scanf(" %c",&a[i]);
}
printf("enter the charcter u want to search:");
scanf(" %c",&ch);
for(i=0;i<10;i++)
{
if(a[i]==ch)
{
count++;
}
}
printf("number of occurance of your entered character is %d",count);
}

No comments:

Contact Form

Name

Email *

Message *