cout strcat string1string2 coutSolution Exercise 1 include i

cout strcat (string1,string2): cout

Solution


Exercise 1

#include<iostream.h>
int main(){
    char string1[50];
    int i, length;
    int flag = 0;
   
    cout << \"Enter a string: \";
    cin >> string1;
   length = strlen(string1);
       for(i=0;i < length ;i++){
        if(string1[i] != string1[length-i-1])
           {
            flag = 1;
            break;
    }
}
   
    if (flag) {
        cout << string1 << \" is not a palindrome\" << endl;
    }   
    else {
        cout << string1 << \" is a palindrome\" << endl;
    }
    return 0;
}

Exercise 2

#include<iostream.h>
#include<string.h>

int main(){
    char name1[25],name2[25];
    int i, length;
    int flag = 0;
   
    cout << \"Enter the first name\";
    cin >> name1;
    cout << \"Enter the second name\";
    cin >> name2;
   
    if(strcmp(name1,name2)>0)
     {
      cout<<\"The names are as follows:\ \"<<name2<<\"\ \"<<name1;
     }
    else if(strcmp(name1,name2)<0)
     {
      cout<<\"The names are as follows:\ \"<<name1<<\"\ \"<<name2;
      }
     else
     cout<<\"The names are as follows:\ \"<<name2<<\"\ \"<<name1;
     return 0;
    }
   

Exercise 3:

#include <iostream>

int main()
{
    char str[50];
    int consonants,length;
    consonants = 0;

    cout << \"Enter a line of string: \";
    cin.getline(str,50);
    length=strlen(str);
       for (int i = 0; i < length; i++)
    {
        if(!(str[i] == \'a\' || str[i] == \'e\' || str[i] == \'i\' || str[i] == \'o\' ||
            str[i] == \'u\'))

        consonants = consonants + 1;
    }
   
    cout << \"Consonants: \" << consonants << endl;
    return 0;
}

 cout strcat (string1,string2): coutSolution Exercise 1 #include<iostream.h> int main(){ char string1[50]; int i, length; int flag = 0; cout << \
 cout strcat (string1,string2): coutSolution Exercise 1 #include<iostream.h> int main(){ char string1[50]; int i, length; int flag = 0; cout << \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site