1)
#include
using std::cout;
using std::cin;
using std::endl;
int main()
{
char s[20];
cout << "What is your name: ";<br> cin >> s;
cout << "Hello, " << s << endl;<br>
return 0;
}
2)
#include
using std::cout;
using std::cin;
using std::endl;
#include
using std::strlen;
int main()
{
char s[100];
cout << "Enter the string: ";<br> cin.getline(s, 100);
for(int i = strlen(s) - 1; i >= 0; i--)
{
cout << s[i];<br> }
cout << endl;<br>
return 0;
}
3)
#include
using std::cout;
using std::cin;
using std::endl;
#include
using std::strlen;
int main()
{
char s[20];
bool x = true;
cout << "Enter the word: ";<br> cin.getline(s, 100);
for(int i = 0, j = strlen(s) - 1; i <= j; i++, j--)<br> {
if(s[i] != s[j])
{
x = false;
break;
}
}
if(x)
{
cout << "Palindrome" << endl;<br> }
else
cout << "Not palindrome" << endl;<br>
return 0;
}
4)
#include
using std::cout;
using std::cin;
using std::endl;
#include
using std::strlen;
int main()
{
char s[100];
char n;
cout << "Enter the string: ";<br> cin.getline(s, 100);
for(int i = 0; i < strlen(s); i++)
{
if(s[i] == 'a')
{
n = 'a';
break;
}
else if(s[i] == 'o')
{
n = 'o';
break;
}
}
if(n == 'a')
{
cout << "\nThe first letter of A" << endl;<br> }
else if(n == 'o')
{
cout << "\nThe first letter of O" << endl;<br> }
else
cout << "These letters are not available" << endl;<br>
return 0;
}