SlideShare a Scribd company logo
1 of 3
Objective: To examine a user-entered string to determine if it's a palindrome. A palindrome is a
word that is spelled the same forward and backward, such as "radar" or "madam." Your
program should ask the user to enter a word, and then tell the user whether or not that word is a
palindrome. Your program doesn't need to determine whether or not the word is in the English
language. But you can assume that the word is made up of lower-case letters only, and that it is
no more than 20 letters long. So for example your program would determine that the word
"abcdefghijjihgfedcba" is a palindrome. Here is some sample output from the program: Please
enter a word: radar The word you entered, 'radar' is a palindrome. bash-2.04$ a.out Please enter
a word: abccba The word you entered: 'abccba' is a palindrome. bash-2.04$ a.out Please enter a
word: abcddxba The word you entered: 'abcddxba' is not a palindrome. Requirements: Your
program must use at least one function in addition to main. You must use a c-string (null-
terminated character array) to store the word the user enters (as we have been doing all
semester). You are not allowed to use the class "string" in this program. To determine how
many characters are in a c-string, use the strlen function. You will need to "#include ", and then
if you have a c-string called "str" you can store its length in the variable "len" you would
write: "len = strlen(str);" Test your program with all of the above test cases. Save both the
source code and the output it produced after you compiled and ran it. You should save these in a
plain text file with a file extension of either .txt or .cpp. Put comments at the top of your program
with your name, the name of your C++ source file, the name of this assignment and class (CS
110A Lab 5), and a brief description of what the program does. Format it so that it is readable
and professional. Follow the standard conventions for indentation, meaningful variable names,
etc. like the textbook.
Solution
#include<stdio.h>
#include<cstring>
int isPalindrome(char word[])
{
int length,i,j;
length=strlen(word);
i=0;
j=length-1;
while(i<length/2)
{
if(word[i]!=word[j])
return 0;
i++;
j--;
}
return 1;
}
int main()
{
char input_word[21];
printf("Please enter a word:");
scanf("%",input_word);
if(isPalindrome(input_word))
printf("The word you entered,'%' is a palindrome. ",input_word);
else
printf("The word you entered,'%' is not a palindrome. ",input_word);
return 0;
}
Objective- To examine a user-entered string to determine if it-'s a pa.docx

More Related Content

Similar to Objective- To examine a user-entered string to determine if it-'s a pa.docx

Devry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringsDevry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringsnoahjamessss
 
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringsDevry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringscskvsmi44
 
COMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docx
COMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docxCOMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docx
COMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docxdonnajames55
 
2019 session 5 describe different basic programming codes and languages
2019 session 5 describe different basic programming codes and languages2019 session 5 describe different basic programming codes and languages
2019 session 5 describe different basic programming codes and languagesOsama Ghandour Geris
 
Learn C# programming - Program Structure & Basic Syntax
Learn C# programming - Program Structure & Basic SyntaxLearn C# programming - Program Structure & Basic Syntax
Learn C# programming - Program Structure & Basic SyntaxEng Teong Cheah
 
Fundamental of C Programming Language and Basic Input/Output Function
  Fundamental of C Programming Language and Basic Input/Output Function  Fundamental of C Programming Language and Basic Input/Output Function
Fundamental of C Programming Language and Basic Input/Output Functionimtiazalijoono
 
Hey, I need some help coding this C++ assignment.ObjectivesThis.pdf
Hey, I need some help coding this C++ assignment.ObjectivesThis.pdfHey, I need some help coding this C++ assignment.ObjectivesThis.pdf
Hey, I need some help coding this C++ assignment.ObjectivesThis.pdfrishabjain5053
 
Devry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and stringsDevry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and stringsjody zoll
 
Lecture 0 - CS50's Introduction to Programming with Python.pdf
Lecture 0 - CS50's Introduction to Programming with Python.pdfLecture 0 - CS50's Introduction to Programming with Python.pdf
Lecture 0 - CS50's Introduction to Programming with Python.pdfSrinivasPonugupaty1
 
Programming in C - interview questions.pdf
Programming in C - interview questions.pdfProgramming in C - interview questions.pdf
Programming in C - interview questions.pdfSergiuMatei7
 
Cosc 1436 java programming/tutorialoutlet
Cosc 1436 java programming/tutorialoutletCosc 1436 java programming/tutorialoutlet
Cosc 1436 java programming/tutorialoutletWoodardz
 
Java script final presentation
Java script final presentationJava script final presentation
Java script final presentationAdhoura Academy
 
Solid C++ by Example
Solid C++ by ExampleSolid C++ by Example
Solid C++ by ExampleOlve Maudal
 
C programming day#3.
C programming day#3.C programming day#3.
C programming day#3.Mohamed Fawzy
 
Chapter3
Chapter3Chapter3
Chapter3Kamran
 
Wade not in unknown waters. Part two.
Wade not in unknown waters. Part two.Wade not in unknown waters. Part two.
Wade not in unknown waters. Part two.PVS-Studio
 

Similar to Objective- To examine a user-entered string to determine if it-'s a pa.docx (20)

Devry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringsDevry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
 
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringsDevry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
 
COMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docx
COMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docxCOMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docx
COMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docx
 
Python
PythonPython
Python
 
2019 session 5 describe different basic programming codes and languages
2019 session 5 describe different basic programming codes and languages2019 session 5 describe different basic programming codes and languages
2019 session 5 describe different basic programming codes and languages
 
Learn C# programming - Program Structure & Basic Syntax
Learn C# programming - Program Structure & Basic SyntaxLearn C# programming - Program Structure & Basic Syntax
Learn C# programming - Program Structure & Basic Syntax
 
Fundamental of C Programming Language and Basic Input/Output Function
  Fundamental of C Programming Language and Basic Input/Output Function  Fundamental of C Programming Language and Basic Input/Output Function
Fundamental of C Programming Language and Basic Input/Output Function
 
Hey, I need some help coding this C++ assignment.ObjectivesThis.pdf
Hey, I need some help coding this C++ assignment.ObjectivesThis.pdfHey, I need some help coding this C++ assignment.ObjectivesThis.pdf
Hey, I need some help coding this C++ assignment.ObjectivesThis.pdf
 
Let's us c language (sabeel Bugti)
Let's us c language (sabeel Bugti)Let's us c language (sabeel Bugti)
Let's us c language (sabeel Bugti)
 
Devry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and stringsDevry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and strings
 
Lecture 0 - CS50's Introduction to Programming with Python.pdf
Lecture 0 - CS50's Introduction to Programming with Python.pdfLecture 0 - CS50's Introduction to Programming with Python.pdf
Lecture 0 - CS50's Introduction to Programming with Python.pdf
 
Csharp_Chap01
Csharp_Chap01Csharp_Chap01
Csharp_Chap01
 
C programming
C programmingC programming
C programming
 
Programming in C - interview questions.pdf
Programming in C - interview questions.pdfProgramming in C - interview questions.pdf
Programming in C - interview questions.pdf
 
Cosc 1436 java programming/tutorialoutlet
Cosc 1436 java programming/tutorialoutletCosc 1436 java programming/tutorialoutlet
Cosc 1436 java programming/tutorialoutlet
 
Java script final presentation
Java script final presentationJava script final presentation
Java script final presentation
 
Solid C++ by Example
Solid C++ by ExampleSolid C++ by Example
Solid C++ by Example
 
C programming day#3.
C programming day#3.C programming day#3.
C programming day#3.
 
Chapter3
Chapter3Chapter3
Chapter3
 
Wade not in unknown waters. Part two.
Wade not in unknown waters. Part two.Wade not in unknown waters. Part two.
Wade not in unknown waters. Part two.
 

More from dorisevans99695

A material effect from changing accounting principles should be report.docx
A material effect from changing accounting principles should be report.docxA material effect from changing accounting principles should be report.docx
A material effect from changing accounting principles should be report.docxdorisevans99695
 
a system consists of four components connected as shown assume A B C.docx
a system consists of four components connected as shown  assume A B C.docxa system consists of four components connected as shown  assume A B C.docx
a system consists of four components connected as shown assume A B C.docxdorisevans99695
 
A SWOT analysis is conducted during what stage of the HR planning proc.docx
A SWOT analysis is conducted during what stage of the HR planning proc.docxA SWOT analysis is conducted during what stage of the HR planning proc.docx
A SWOT analysis is conducted during what stage of the HR planning proc.docxdorisevans99695
 
A survey was conducted where people were asked whether they have a pre.docx
A survey was conducted where people were asked whether they have a pre.docxA survey was conducted where people were asked whether they have a pre.docx
A survey was conducted where people were asked whether they have a pre.docxdorisevans99695
 
A survey asked what part of the country respondents live in and whethe.docx
A survey asked what part of the country respondents live in and whethe.docxA survey asked what part of the country respondents live in and whethe.docx
A survey asked what part of the country respondents live in and whethe.docxdorisevans99695
 
A student is interested in how many dogs were detected with the eDNA s.docx
A student is interested in how many dogs were detected with the eDNA s.docxA student is interested in how many dogs were detected with the eDNA s.docx
A student is interested in how many dogs were detected with the eDNA s.docxdorisevans99695
 
A student goes to the library- The probability that she checks out (a).docx
A student goes to the library- The probability that she checks out (a).docxA student goes to the library- The probability that she checks out (a).docx
A student goes to the library- The probability that she checks out (a).docxdorisevans99695
 
A stock has a return on equity of 17-5- and a plowback ratio of 35-- W.docx
A stock has a return on equity of 17-5- and a plowback ratio of 35-- W.docxA stock has a return on equity of 17-5- and a plowback ratio of 35-- W.docx
A stock has a return on equity of 17-5- and a plowback ratio of 35-- W.docxdorisevans99695
 
A small town collected data on their citizens most frequent mode of tr.docx
A small town collected data on their citizens most frequent mode of tr.docxA small town collected data on their citizens most frequent mode of tr.docx
A small town collected data on their citizens most frequent mode of tr.docxdorisevans99695
 
A serious developmental disorder associated with multiple -thalassemia.docx
A serious developmental disorder associated with multiple -thalassemia.docxA serious developmental disorder associated with multiple -thalassemia.docx
A serious developmental disorder associated with multiple -thalassemia.docxdorisevans99695
 
A sequence of four tasks is part of the project schedule- Each of the.docx
A sequence of four tasks is part of the project schedule- Each of the.docxA sequence of four tasks is part of the project schedule- Each of the.docx
A sequence of four tasks is part of the project schedule- Each of the.docxdorisevans99695
 
A researcher measures a response variable Y and an explanatory variabl.docx
A researcher measures a response variable Y and an explanatory variabl.docxA researcher measures a response variable Y and an explanatory variabl.docx
A researcher measures a response variable Y and an explanatory variabl.docxdorisevans99695
 
A protein that evolved to live inside of the membranes of the cell- A-.docx
A protein that evolved to live inside of the membranes of the cell- A-.docxA protein that evolved to live inside of the membranes of the cell- A-.docx
A protein that evolved to live inside of the membranes of the cell- A-.docxdorisevans99695
 
A protein that evolved to live in the cytoplasm (or other water locati.docx
A protein that evolved to live in the cytoplasm (or other water locati.docxA protein that evolved to live in the cytoplasm (or other water locati.docx
A protein that evolved to live in the cytoplasm (or other water locati.docxdorisevans99695
 
a population has mean u- 13 and standard deviation o-4- what is the z.docx
a population has mean u- 13 and standard deviation o-4- what is the z.docxa population has mean u- 13 and standard deviation o-4- what is the z.docx
a population has mean u- 13 and standard deviation o-4- what is the z.docxdorisevans99695
 
A population has a mean -70 and a standard deviation -9- Find the mean.docx
A population has a mean -70 and a standard deviation -9- Find the mean.docxA population has a mean -70 and a standard deviation -9- Find the mean.docx
A population has a mean -70 and a standard deviation -9- Find the mean.docxdorisevans99695
 
A person used as an example for other employees to show the best in de.docx
A person used as an example for other employees to show the best in de.docxA person used as an example for other employees to show the best in de.docx
A person used as an example for other employees to show the best in de.docxdorisevans99695
 
A patient recently received a diagnostic tap for a large pleural effus.docx
A patient recently received a diagnostic tap for a large pleural effus.docxA patient recently received a diagnostic tap for a large pleural effus.docx
A patient recently received a diagnostic tap for a large pleural effus.docxdorisevans99695
 
A patient has newborn twins- One is healthy- with natural color to li.docx
A patient has newborn twins-  One is healthy- with natural color to li.docxA patient has newborn twins-  One is healthy- with natural color to li.docx
A patient has newborn twins- One is healthy- with natural color to li.docxdorisevans99695
 
A partner has a capital balance of $40000 Jenuary to April $50-000 tro.docx
A partner has a capital balance of $40000 Jenuary to April $50-000 tro.docxA partner has a capital balance of $40000 Jenuary to April $50-000 tro.docx
A partner has a capital balance of $40000 Jenuary to April $50-000 tro.docxdorisevans99695
 

More from dorisevans99695 (20)

A material effect from changing accounting principles should be report.docx
A material effect from changing accounting principles should be report.docxA material effect from changing accounting principles should be report.docx
A material effect from changing accounting principles should be report.docx
 
a system consists of four components connected as shown assume A B C.docx
a system consists of four components connected as shown  assume A B C.docxa system consists of four components connected as shown  assume A B C.docx
a system consists of four components connected as shown assume A B C.docx
 
A SWOT analysis is conducted during what stage of the HR planning proc.docx
A SWOT analysis is conducted during what stage of the HR planning proc.docxA SWOT analysis is conducted during what stage of the HR planning proc.docx
A SWOT analysis is conducted during what stage of the HR planning proc.docx
 
A survey was conducted where people were asked whether they have a pre.docx
A survey was conducted where people were asked whether they have a pre.docxA survey was conducted where people were asked whether they have a pre.docx
A survey was conducted where people were asked whether they have a pre.docx
 
A survey asked what part of the country respondents live in and whethe.docx
A survey asked what part of the country respondents live in and whethe.docxA survey asked what part of the country respondents live in and whethe.docx
A survey asked what part of the country respondents live in and whethe.docx
 
A student is interested in how many dogs were detected with the eDNA s.docx
A student is interested in how many dogs were detected with the eDNA s.docxA student is interested in how many dogs were detected with the eDNA s.docx
A student is interested in how many dogs were detected with the eDNA s.docx
 
A student goes to the library- The probability that she checks out (a).docx
A student goes to the library- The probability that she checks out (a).docxA student goes to the library- The probability that she checks out (a).docx
A student goes to the library- The probability that she checks out (a).docx
 
A stock has a return on equity of 17-5- and a plowback ratio of 35-- W.docx
A stock has a return on equity of 17-5- and a plowback ratio of 35-- W.docxA stock has a return on equity of 17-5- and a plowback ratio of 35-- W.docx
A stock has a return on equity of 17-5- and a plowback ratio of 35-- W.docx
 
A small town collected data on their citizens most frequent mode of tr.docx
A small town collected data on their citizens most frequent mode of tr.docxA small town collected data on their citizens most frequent mode of tr.docx
A small town collected data on their citizens most frequent mode of tr.docx
 
A serious developmental disorder associated with multiple -thalassemia.docx
A serious developmental disorder associated with multiple -thalassemia.docxA serious developmental disorder associated with multiple -thalassemia.docx
A serious developmental disorder associated with multiple -thalassemia.docx
 
A sequence of four tasks is part of the project schedule- Each of the.docx
A sequence of four tasks is part of the project schedule- Each of the.docxA sequence of four tasks is part of the project schedule- Each of the.docx
A sequence of four tasks is part of the project schedule- Each of the.docx
 
A researcher measures a response variable Y and an explanatory variabl.docx
A researcher measures a response variable Y and an explanatory variabl.docxA researcher measures a response variable Y and an explanatory variabl.docx
A researcher measures a response variable Y and an explanatory variabl.docx
 
A protein that evolved to live inside of the membranes of the cell- A-.docx
A protein that evolved to live inside of the membranes of the cell- A-.docxA protein that evolved to live inside of the membranes of the cell- A-.docx
A protein that evolved to live inside of the membranes of the cell- A-.docx
 
A protein that evolved to live in the cytoplasm (or other water locati.docx
A protein that evolved to live in the cytoplasm (or other water locati.docxA protein that evolved to live in the cytoplasm (or other water locati.docx
A protein that evolved to live in the cytoplasm (or other water locati.docx
 
a population has mean u- 13 and standard deviation o-4- what is the z.docx
a population has mean u- 13 and standard deviation o-4- what is the z.docxa population has mean u- 13 and standard deviation o-4- what is the z.docx
a population has mean u- 13 and standard deviation o-4- what is the z.docx
 
A population has a mean -70 and a standard deviation -9- Find the mean.docx
A population has a mean -70 and a standard deviation -9- Find the mean.docxA population has a mean -70 and a standard deviation -9- Find the mean.docx
A population has a mean -70 and a standard deviation -9- Find the mean.docx
 
A person used as an example for other employees to show the best in de.docx
A person used as an example for other employees to show the best in de.docxA person used as an example for other employees to show the best in de.docx
A person used as an example for other employees to show the best in de.docx
 
A patient recently received a diagnostic tap for a large pleural effus.docx
A patient recently received a diagnostic tap for a large pleural effus.docxA patient recently received a diagnostic tap for a large pleural effus.docx
A patient recently received a diagnostic tap for a large pleural effus.docx
 
A patient has newborn twins- One is healthy- with natural color to li.docx
A patient has newborn twins-  One is healthy- with natural color to li.docxA patient has newborn twins-  One is healthy- with natural color to li.docx
A patient has newborn twins- One is healthy- with natural color to li.docx
 
A partner has a capital balance of $40000 Jenuary to April $50-000 tro.docx
A partner has a capital balance of $40000 Jenuary to April $50-000 tro.docxA partner has a capital balance of $40000 Jenuary to April $50-000 tro.docx
A partner has a capital balance of $40000 Jenuary to April $50-000 tro.docx
 

Recently uploaded

Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationNeilDeclaro1
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxUmeshTimilsina1
 

Recently uploaded (20)

Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health Education
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 

Objective- To examine a user-entered string to determine if it-'s a pa.docx

  • 1. Objective: To examine a user-entered string to determine if it's a palindrome. A palindrome is a word that is spelled the same forward and backward, such as "radar" or "madam." Your program should ask the user to enter a word, and then tell the user whether or not that word is a palindrome. Your program doesn't need to determine whether or not the word is in the English language. But you can assume that the word is made up of lower-case letters only, and that it is no more than 20 letters long. So for example your program would determine that the word "abcdefghijjihgfedcba" is a palindrome. Here is some sample output from the program: Please enter a word: radar The word you entered, 'radar' is a palindrome. bash-2.04$ a.out Please enter a word: abccba The word you entered: 'abccba' is a palindrome. bash-2.04$ a.out Please enter a word: abcddxba The word you entered: 'abcddxba' is not a palindrome. Requirements: Your program must use at least one function in addition to main. You must use a c-string (null- terminated character array) to store the word the user enters (as we have been doing all semester). You are not allowed to use the class "string" in this program. To determine how many characters are in a c-string, use the strlen function. You will need to "#include ", and then if you have a c-string called "str" you can store its length in the variable "len" you would write: "len = strlen(str);" Test your program with all of the above test cases. Save both the source code and the output it produced after you compiled and ran it. You should save these in a plain text file with a file extension of either .txt or .cpp. Put comments at the top of your program with your name, the name of your C++ source file, the name of this assignment and class (CS 110A Lab 5), and a brief description of what the program does. Format it so that it is readable and professional. Follow the standard conventions for indentation, meaningful variable names, etc. like the textbook. Solution #include<stdio.h> #include<cstring> int isPalindrome(char word[]) { int length,i,j; length=strlen(word);
  • 2. i=0; j=length-1; while(i<length/2) { if(word[i]!=word[j]) return 0; i++; j--; } return 1; } int main() { char input_word[21]; printf("Please enter a word:"); scanf("%",input_word); if(isPalindrome(input_word)) printf("The word you entered,'%' is a palindrome. ",input_word); else printf("The word you entered,'%' is not a palindrome. ",input_word); return 0; }