String Contain the textual data and empty space. In this Problem we deal with String to find a Character in String given by user. User will enter a Sentence in Command Prompt and after this Program will asked user to enter the alphabet that want to search . If that Character exist is String program will display message " exist" else Not exist.
Source Code
#include<iostream> #include<conio.h> #include<stdio.h> using namespace std; int main() { char str[30]; int i; char ch; bool p=true; cout<<"\n *************** SEARCH CHARACHTER IN STRING ************** \n\n\n"; cout<<"\n Enter String : "; gets(str); cout<<"\n\n Enter Character You Want To Search= "; cin>>ch; for(i=0;i<=strlen(str);i++) { if(str[i]==ch) { p=false; break; } } if(p==true) { cout<<"\n\n Character Not Present In String \n\n"; } else { cout<<"\n\n Character Present In String"; } return 0; }
0 comments:
Post a Comment