Given the variable n of type int and the variable s is of type string, translate the following conditions to C++.
1. n is at least 10.
2. s begins and ends with the same letter.
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
string s[100];
cout<<"Enter a number: "<<endl;
cin>>n;
if (n < 10)
{
cout<<"Enter a number greater than 10";
cin>>n;
}
cout<<"Enter a string: "<<endl;
cin>>s[100];
if (s[0] != s[-1])
{
cout<<"String has to be begin and end with same letter";
cin>>s[100];
}
}
Comments
Leave a comment