SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Similaire à 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
 

Similaire à 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.
 

Plus de 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
 

Plus de 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
 

Dernier

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
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
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
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
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
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
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
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
 

Dernier (20)

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
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
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
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
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
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...
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
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...
 

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; }