Answer:
#include <iostream>
#include <array>
using namespace std;
bool isPalindrome(string str)
{
int length = str.length();
for (int i = 0; i < length / 2; i++)
if (toupper(str[i]) != toupper(str[length - 1 - i]))
return false;
return true;
}
int main()
{
array<string, 6> tests = { "madam", "abba", "22", "67876", "444244", "trymEuemYRT" };
for (auto test : tests) {
cout << test << " is " << (isPalindrome(test) ? "" : "NOT ") << "a palindrome.\n";
}
}
Explanation:
The toupper() addition forces characters to uppercase, thereby making the comparison case insensitive.
Answer:
This is true.
Explanation:
I think everyone was taught to to type correctly sometime in school or at home. It helps you proficiently type. But most people don't use the Home Room Key Technique. Most use the "Chicken peck"
Answer:
I am writing a Python program that deletes players from the file whose names whose names do not begin with a vowel which means their names begin with a consonant instead. Since the SomePlayers.txt is not provided so i am creating this file. You can simply use this program on your own file.
fileobj= open('SomePlayers.txt', 'r')
player_names=[name.rstrip() for name in fileobj]
fileobj.close()
vowels = ('a', 'e', 'i', 'o', 'u','A','E','I','O','U')
player_names=[name for name in player_names
if name[0] in vowels]
fileobj.close()
print(player_names)
Explanation:
I will explain the program line by line.
First SomePlayers.txt is opened in r mode which is read mode using open() method. fileobj is the name of the file object created to access or manipulate the SomePlayers.txt file. Next a for loop is used to move through each string in the text file and rstrip() method is used to remove white spaces from the text file and stores the names in player_names. Next the file is closed using close() method. Next vowels holds the list of characters which are vowels including both the upper and lower case vowels.
player_names=[name for name in player_names
if name[0] in vowels]
This is the main line of the code. The for loop traverses through every name string in the text file SomePlayers.txt which was first stored in player_names when rstrip() method was used. Now the IF condition checks the first character of each name string. [0] is the index position of the first character of each players name. So the if condition checks if the first character of the name is a vowel or not. in keyword is used here to check if the vowel is included in the first character of every name in the file. This will separate all the names that begins with a vowel and stores in the list player_names. At the end the print statement print(player_names) displays all the names included in the player_names which begin with a vowel hence removing all those names do not begin with a vowel.
Answer:
90%
Explanation:
90%
ELO 4.2 A department requires access to the database application from Monday to Friday, 9AM to 5 PM. Last Thursday at 1 PM, the application crashed, and it took six hours to fix the problem. What was the availability of the application during the week?
Answer:
False
Explanation:
The scheme where you can find the greatest common divisor (GCD) of two integers by repetitive application of the division algorithm is known as Euclidean Algorithm.
The Euclidean Algorithm for calculating GCD of two numbers X and Y can be given as follows:
- If X=0 then GCD(X, Y)=Y since the Greatest Common Divisor of 0 and Y is Y.
- If Y=0 then GCD(X, Y)=X since the Greates Common Divisor of 0 and X is X.
- Let R be the remainder of dividing X by Y assuming X > Y. (R = X % Y)
- Find GCD( Y, R ) because GCD( X, Y ) = GCD(Y, R ).
- Repeat the above steps again till R = 0.