Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- void stringArray(char *); //method declaration
- void strFunc(string );
- int main()
- {
- //char arr1[6] = {'H','E','L','L','O','\0'};
- string str="Hello World as";
- //int wordCount=0;
- // bool flag = false;
- /*for (int i=0; i<str.size(); i++) {
- if(str[i]!=' ') {
- if (flag=false){
- wordCount++;
- flag = true;
- }
- else {
- flag=false;
- }
- }
- }
- cout<<"Word Count: "<<wordCount<<endl;
- */
- strFunc(str);
- cout<<str<<endl;
- string strReverse = "";
- for(int i=str.size()-1; i>=0; i--) {
- //strReverse=strReverse+str[i];
- strReverse += str[i];
- }
- cout<<strReverse<<endl;
- string b = "MOS";
- string c = "";
- for(int i=b.size()-1;i>=0; i--) {
- c+=b[i];
- }
- if (b==c) {
- cout<<"Palindrome found"<<endl;
- }
- else{
- cout<<"Palindrome not found"<<endl;
- }
- return 0;
- }
- void strFunc(string a) {
- //cout<<a<<endl;
- //a[0] = 'E';
- //cout<<a<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement