Answer:
The code will display the following on the screen:-
2
0
2
Explanation:
The output is like this because x{2} assigns the value 2 to the integer x.First the value of x is printed on the screen that is 2 and that newline is used to go to the next line.After that function is called doSomething with x passed as the argument. doSomething function assigns the value zero to the variable passed and prints it on the screen.So the next line is 0.Since x is passed by value so no changes will appear in the original argument.Hence the last line printed is 2.
Answer:
#include <bits/stdc++.h>
using namespace std;
bool isPalindrome(string str)
{
char a,b;
int length = str.length();
for (int i = 0; i < length / 2; i++)
{
a=tolower(str[i]);//Converting both first characters to lowercase..
b=tolower(str[length-1-i]);
if (b != a )
return false;
}
return true;
}
int main() {
string t1;
cin>>t1;
if(isPalindrome(t1))
cout<<"The string is Palindrome"<<endl;
else
cout<<"The string is not Palindrome"<<endl;
return 0;
}
Output:-
Enter the string
madam
The string is Palindrome
Enter the string
abba
The string is Palindrome
Enter the string
22
The string is Palindrome
Enter the string
67876
The string is Palindrome
Enter the string
444244
The string is not Palindrome
Explanation:
To ignore the cases of uppercase and lower case i have converted every character to lowercase then checking each character.You can convert to uppercase also that will also work.
<h2>
Answer:</h2><h2>
Oh yes you can. </h2>
Click slowly twice the folder.
Right click and choose rename.