1answer.
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
olganol [36]
4 years ago
6

Write a C++ program that determines if a given string is a palindrome. A palindrome is a word or phrase that reads the same back

ward as forward. Blank, punctuation marks and capitalization do not count in determining palindromes. Here is some examples of palindromes:
Radar
Too hot to hoot
Madam!I'm adam
Computers and Technology
1 answer:
Ostrovityanka [42]4 years ago
6 0

The cpp program to determine if the given string is palindrome, is shown below.

The program has comments at places to indicate the logic.

#include <iostream>

#include <string.h>

using namespace std;

int main() {

// string is taken as an array of characters of size 50

char str1[50];

int i, len, flag;

cout<<"Enter any string to check for palindrome"<<endl;

cin>>str1;

// length of input string is stored in variable len to be used in the loop

len = strlen(str1)-1;

for(i=0; i<=len; i++)

{

// if string is palindrome, value of flag variable is initialized to 0 else 1

   if(str1[i]==str1[len-i])

        flag = 0;

           else

                flag = 1;

}

if (flag == 0)

       cout << str1 << " is a palindrome";

   else

       cout << str1 << " is not a palindrome";      

// returns integer value since main has return type of integer  

   return 0;

}

Explanation:

The header files for input and output and string are imported.

#include <iostream>

#include <string.h>

The string is taken as an array of type char having adequate size of 50.

char str1[50];

The length of the input string is calculated as

len = strlen(str1)-1;

Within a single for loop using a single variable and the length of the string, we check whether the string is palindrome or not.

      for(i=0; i<=len; i++)

{

   if(str1[i]==str1[len-i])

        flag = 0;

            else

                flag = 1;

}

The int flag is declared but not initialized.

If the string is palindrome, the value of flag variable becomes 0. Otherwise, the value of flag variable will be initialized to 1.

Depending on the value of flag variable, the message is displayed if the input string is palindrome or not.

The above program works for all strings irrespective of special characters which may be included in the string.

The above program also works for the examples of input string given in the question.

You might be interested in
Someone once observed that "the difference between roles and groups is that a user can shift into and out of roles, whereas that
mestny [16]

Answer:

All things considered newgrp has nothing to do with security jobs.  

newgrp sets the procedures bunch id which is in many frameworks are irrelevant. All gatherings are accessible. Gatherings are characterized as assortment of clients , bunch get to is conceded to documents dependent on the record gathering.  

Regularly (setgroups/getgroups ) all gatherings are in the process get to list.  

The authorization at a document or registry level has a 3 level arrangement of consents, for example, client proprietorship , bunch possession and others. All things considered the document authorization are a mix of read , compose and execute .we need both peruse and execute consent to run a program.  

A procedure may get to the document if a record has a place with the user(the proprietor of the document ) or if the gathering identifier coordinate on the gatherings in the clients bunches list. That entrance is constrained by the relating consents signals on the record.  

Gatherings have been over-burden with some "job" definitions. In any case, these are just over-burden and not a decent utilization of groups,the utilization of a gathering as a job was bolstered by the setgroup id banner , and by utilities like a sudo , where gathering name likewise coordinates a security control. It expect that the gathering name isn't utilized for documents yet once a client is in the gathering that client can apply the gathering to a record regardless of whether it isn't what the gathering was for.  

This over-burden use worked where frameworks didn't bolster genuine jobs. The over-burden utilize was only a work around.  

Linux has genuine job definition bolstered by SELinux models and can be applied to documents , clients , and forms.

7 0
4 years ago
Complete the rest of this statement:
Radda [10]

Answer:

Computer science is about how computers work, in terms of programming, design and data processing.

Explanation:

Computer science is a discipline that studies issues related to information technology and its use, including the storage, processing, presentation, and transfer of information.

The fringes of computer science extend to many other sciences: for example, usability research is closely related to psychology and bioinformatics to biology, among others. Digital media research, on the other hand, has links to media science and communications research. Computer science also has a strong interaction with computational science and information society research examining the wider effects of data processing in different areas.

4 0
3 years ago
____ elements are arranged to show which tasks must be completed before subsequent dependent tasks can begin.
Masteriza [31]
The answer is Gantt Chart
5 0
4 years ago
Lola wants to install an add-in in Excel.She has to unblock the add-in to allow Excel to open the add-in file automatically.To d
ololo11 [35]

Answer:

The correct answer is:

Properties (D)

Explanation:

First of all, option D (Properties) is the option that makes the most sense in this scenario, because the other options: Copy, Delete, and Rename are unrelated commands to what is to be achieved.

Secondly and more practically, an add-in file may not load in excel, and most of the time it is blocked by default and has to be unblocked. The following steps are used:

1. close Excel if it is open

2. open the folder where the add-in file is located, right-click on the add-in file, and select "properties"

3. a display tray will appear, having the attributes: Read-only, Hidden, Advanced, and unblock. Click the checkbox against "unblock" and make sure it is checked.

4. click Apply and Click Ok

Voila, your add-in file is unblocked.

<em>N:B The Images are for steps 2 and 3</em>

5 0
3 years ago
Can someone write what happened on thanksgiving but with a twist please..
swat32

Answer:

We went to (your family name) house and were having an amazing dinner when all of a sudden... crrrraaaaaackkkkkk! My (sibling gender) dropped the plates s/he was carrying. They were china too! It ruined the party and caused he/r to break put in tears. We tried to comfort them but they ran off and hid in a corner .............(your turn)

Explanation:

English major;)

7 0
1 year ago
Other questions:
  • You have been asked to create an authentication security plan for your company. Which of the following components would you inco
    14·1 answer
  • In Linux Operating System, what file extension is used forexecutable files?
    6·1 answer
  • Select all examples of good keyboarding technique.
    13·2 answers
  • What shooting position is commonly used when hunting with a shotgun?
    14·2 answers
  • Establishing responsibilities, planning to best support the organization, acquiring validity, ensuring performance, conformity w
    12·1 answer
  • A user who has special security and access to a system, such as the right to assign passwords, is called a ____.​ a. ​ technical
    8·1 answer
  • Cameron is having a party and needs to write step-by-step directions on the invitation. Which type of list would you
    11·1 answer
  • Complete the second clause of the following Prolog program for member/2 where member(X, Y) checks whether X is an element (a mem
    7·1 answer
  • Please explain what is Ribbon?  give examples​
    7·2 answers
  • In 1956, the unit byte was coined by American statistician and computer scientist John Tukey
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!