#include<stdio.h>
#include<conio.h>
void main()
{
char a[21],b;
int i,j,flag=0;
clrscr();
printf("\n Please Give The STRING OF A : ");
scanf("%s",a);
flushall();
printf("\n Please Give The CHARACTER TO B : ");
scanf("%c",&b);
for(i=0,j=0;a[i]!='\0';i++)
{
if(a[i]==b && flag!=1)
{
j=i+1;
flag=1;
}
}
if(flag==1)
printf("The character %c is at position: %d\n", b,j);
else
printf("The character was not found\n");
getch();
}
--------------------------------- OUTPUT ---------------------------------
Please Give The STRING OF A : NAYAN
Please Give The CHARACTER TO BE FOUND : Y
The character Y is at position: 3
--------------------------------------------------------------------------