PPS Practical 37
- Aim: Write a program to find a character from given string.
- Code:
//For turbo C++ remove below comments #include <stdio.h> //#include<conio.h> void main() { char s[99],f; int i,pos; //clrscr(); printf("Enter string : "); gets(s); printf("Enter character to find in string: "); scanf("%c",&f); for (i = 0; s[i]!='\0' ; i++){ if (s[i]==f){ pos=i; break; } } printf("position of character %c in string '%s' is : %d",f,s,pos+1); // getch(); }
- Output:
Comments
Post a Comment