#include<stdio.h>
#include<conio.h>
void main()
{
int len=0,i,pos,flag;
char a[100],c;
clrscr();
printf("Enter string");
gets(a);
printf("Enter charactor to match");
scanf("%c",&c);
for(len=0;a[len]!=NULL;len++);
for(i=0;i<len;i++)
{
if(a[i]==c)
{
pos=i;
flag=0;
}
}
if(flag==0)
{
printf("%c is matched",c);
printf("\nit is at %d possition from left",pos+1);
printf("\nit is at %d possition from right ",len-pos);
}
else
printf("Not matched");
getch();
}
#include<conio.h>
void main()
{
int len=0,i,pos,flag;
char a[100],c;
clrscr();
printf("Enter string");
gets(a);
printf("Enter charactor to match");
scanf("%c",&c);
for(len=0;a[len]!=NULL;len++);
for(i=0;i<len;i++)
{
if(a[i]==c)
{
pos=i;
flag=0;
}
}
if(flag==0)
{
printf("%c is matched",c);
printf("\nit is at %d possition from left",pos+1);
printf("\nit is at %d possition from right ",len-pos);
}
else
printf("Not matched");
getch();
}
No comments:
Post a Comment