#include
#include
void main()
{
int i=0,len=0,temp=0,count=0,temp1=0;
char a[25],ch,s,con='\0';
clrscr();
printf("\n\t Enter the name: ");
scanf("%s",a);
len=strlen(a);
printf("\n\t The length of the given name is: %d\n",len);
do
{
count=0;
printf("\n\t Enter the character to find : ");
s=getchar();
for(i=0;i
if(s==a[i])
count++;
}
printf("\n\t Occurance is : %d",count);
getch();
printf("\n\t Do you want to find the occurance of characters (Y/y) : ");
con=getchar();
getch();
}while(con=='y'con=='Y');
}
(OR)
printf("\n\t Enter the name: ");
ch=getchar();
a[len]=ch;
while(ch!='\n')
{
len++;
ch=getchar();
printf("\n%c",ch);
a[len]=ch;
}
printf("\n\t The length of the given name is: %d\n",len);
temp1=temp=len;
while(temp!=-1)
{
printf("%c",a[temp]);
temp--;
}
do
{
count=0;
printf("\n\t Enter the character to find : ");
s=getchar();
while(temp1!=0)
{
printf("%c",a[temp1]);
if(s==a[temp1-1])
{
count++;
temp1--;
}
else
temp1--;
}
printf("\n\t Occurance is : %d",count);
getch();
printf("\n\t Do you want to find the occurance of characters (Y/y) : ");
con=getchar();
getch();
}while(con=='y'con=='Y');
*/
Output
Enter the name: haiiii
The length of the given name is: 6
Enter the character to find :i
Occurance is : 4
Do you want to find the occurance of characters (Y/y) :n
No comments:
Post a Comment