answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kvasek [131]
2 years ago
8

5.11 LAB: Palindrome A palindrome is a word or a phrase that is the same when read both forward and backward. Examples are: "bob

," "sees," or "never odd or even" (ignoring spaces). Write a program whose input is a word or phrase, and that outputs whether the input is a palindrome.
Computers and Technology
1 answer:
Jet001 [13]2 years ago
7 0

Answer:

The following are the program in the C++ Programming Language.

// set the header file

#include <iostream>

#include <string>

//set the namespace

using namespace std;

//declare boolean type function

bool Palindrome(string s)  

{

 //set the for loop  

 for (int i = 0; i < s.length(); ++i)  

 {

   //check that s[i] is not equal to length

   if (s[i] != s[s.length() - i - 1])  

   {  

     //then, return false

     return false;

   }

 }

 return true;

}

//declare the main function

int main()  

{

 //declare string type variable

 string st;

 //get string type input in that variable

 getline(cin, st);

 //check the following function is returns true

 if (Palindrome(st))  

 {

   //then, return the following result with message

   cout << st << " is a palindrome" << endl;

 }  

 //otherwise

 else  

 {

   //return the following result with message

   cout << st << " is not a palindrome" << endl;

 }

 return 0;

}

<u>Output</u>:

bob

bob is a palindrome

Explanation:

<u>The following are the description of the program</u>.

  • Set the required header files and namespace then, declare function 'Palindrome()' and pass the string type argument 's' in its parameter.
  • Then, set the for loop statement that iterates from 0 and end at the length of the string, set the if conditional statement that checks the s[i] is not equal to its length, then it returns false otherwise returns true.
  • Finally, declare the main function in which we set the string data type variable 'st' and get the string data type input from the user in it.
  • Then, set the if conditional statement that checks the following function returns true or false.
You might be interested in
The elements of an integer-valued array can be set to 0 (i.e., the array can be cleared) recursively as follows: An array of siz
dangina [55]

Answer:

The method definition to this question can be given as:

Method definition:

public void clear(int[] arr, int num) //define method clear.

{

   if (num == 0) //if block

{

       return 0;  return value.

}

else //else block

{

 arr[num - 1] = 0; //assign value in arr.

return arr[];  //return value.

}

}

clear(arr, num - 1);   //calling

Explanation:

The description of the above method definition as follows:

  • Firstly we define a method that is "clear" that does not return any value because its return type is "void". This method accepts two integer variables that are "arr[] and num" where arr[] is an array variable and num is an integer variable.
  • Inside a method, we use a conditional statement in if block we check that num variable value is equal to 0. if this condition is true so, it will return 0 otherwise it will go to else block in else block it will assign value in variable arr[num-1] that is "0" and return arr value.

4 0
2 years ago
Write a static generic method PairUtil.minmax that computes the minimum and maximum elements of an array of type T and returns a
Gnesinka [82]

Answer:

Explanation:

The following code is written in Java. It is hard to fully create the code without the rest of the needed code including the T class and the Measurable interface. Regardless the following code can be implemented if you have that code available.

 public static T minmax(ArrayList<T> mylist) {

       T min = new T();

       T max = new T();

       for (int x = 0; x < mylist.size(); x++) {

           if (mylist.get(x) > max) {

               max = mylist.get(x);

           } else if (mylist.get(x) < min) {

               min = mylist.get(x);

           }

       }

       

       return (min, max);

   }

5 0
2 years ago
The Tell Me feature also includes access to the _____ feature.
Ierofanga [76]

Answer:

the quick access toolbar can be customized to include additional commands such as. -"tell me what you want to do" box ... custom programs or additional commands that extend the functionality of a Microsoft office program ... in the open window. it also includes ribbon display options and control buttons that enable you to ...

Explanation:

7 0
2 years ago
Give a proof for each statement.
Marrrta [24]

Answer:

  • If a group of 9 kids have won a total of 100 trophies, then at least one of the 9 kids has won at least 12 trophies.
  • If a person buys at least 400 cups of coffee in a year, then there is at least one day in which the person has bought at least two cups of coffee.
  • The average of three real numbers is greater than or equal to at least one of the numbers.

Explanation:

1)

Suppose that  each kid has less than 12 trophies

Total trophies = 100

Maximum trophies won by one kid = 11

total kids = 9

total number of trophies = 9 * 11 = 99 which contradicts the fact the total number of trophies are 100

2)

Suppose that  person has less than 2 cups of coffee a day

Total cups of coffee = 400

he has bought at least one cup of coffee each day

which means

total number of cups of coffee = 1* 366 = 366 which contradicts the fact the person buys at least 400 cups of coffee in a year

3)

Average of three number = (a+ b+ c)/3

suppose that there are real numbers a, b, and c such  that all three numbers are less than the average of the three numbers.

Let m be the average (a+b+c )/3 = m. Then our assumption states that (a < m) and  (b < m) and (c < m). By adding all the inequalities we get a + b + c < 3m. But m is  defined to be (a+b+c) /3  , so a + b + c = 3m.  But now we have that 3m = a + b + c < 3m. So 3m < 3m which is an obvious  contradiction. Thus our claim is true

7 0
2 years ago
What best describes the purpose of the Recycle Bin (Microsoft Windows) and Trash (Apple Mac) features
alexandr1967 [171]
Its to delete the files from the computer that you no longer want. Once its put in the recycling bin it stays there, then when you empty it, its off your computer and there is no way you can get those files back. This can also free-up some space from your computer since mega and giga bites are being removed from your computer.
7 0
2 years ago
Read 2 more answers
Other questions:
  • A chemical found in the synaptic vesicles , which , when released . has an effect on the next cell is called a?
    10·1 answer
  • Janice is unsure about her future career path she has grown up on her family farm but she is also interested in medicine Janice
    5·1 answer
  • True or false? The largest component of a database is a field.
    12·2 answers
  • Assume the secret key is: (1, 2, 3, 4) -&gt; (3, 1, 4, 2); assume the plaintext THEYLOVEIT. If the sub-block length is 3, what i
    6·1 answer
  • In __________ mode, the data within an ip packet is encrypted, but the header information is not.
    15·1 answer
  • A variable like user_num can store a value like an integer. Extend the given program as indicated. Output the user's input. (2 p
    9·1 answer
  • (NumberFormatException)Write the bin2Dec(String binaryString) method to convert a binary string into a decimal number. Implement
    11·1 answer
  • The elements of an integer-valued array can be initialized so that a[i] == i in a recursive fashion as follows: An array of size
    10·1 answer
  • The signature area in a cover letter includes the sender's first and last name, followed by his/her job title (if applicable). *
    13·1 answer
  • Which bus slot provides highest video performance​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!