SlideShare une entreprise Scribd logo
1  sur  3
Palindromes
A palindrome is a word or phrase that reads the same backwards and forwards, ignoring
punctuation, spaces, and anything that isn’t a letter.
Examples of Palindromes
Madam, I’m Adam.
Kayak
Racecar
A man, a plan, a canal – Panama!
Able was I, ere I saw Elba.
C Program ONLY (Please not C++ or Java)
I need to write a program that does the following: *USING STRINGS TO PERFORM THE
FOLLOWING*:
1. opens a text file named “Lab12input.txt― containing multiple lines of text (.txt file has
been provided already just need code to open .txt file)
2. for each line, print out “Palindrome:― and then the line of text if it IS a palindrome, and
print out “Not a palindrome:― and the line of text if it is NOT a palindrome.
Thanks!
Solution
int checkispallindrome(char* string)
{
int i;
int l = strlen(string);
for (i = 0; i < l / 2; i++)
{
if (string[i] != string[l - i - 1])
cout<<”not a palindrome”;
}
cout<<”it is a palindrome”;
}
int main()
{
FILE* f = fopen("myfile.txt", "r");
char string[10];
while(fscanf(f, "%s", string) > 0)
{
checkispallindrome(string;
printf("%s ", string);
}
}
Palindromes A palindrome is a word or phrase that reads the same backw (2).docx

Contenu connexe

Plus de lmark1

The December 31- 2012- balance sheet for Thomas Company showed total s.docx
The December 31- 2012- balance sheet for Thomas Company showed total s.docxThe December 31- 2012- balance sheet for Thomas Company showed total s.docx
The December 31- 2012- balance sheet for Thomas Company showed total s.docxlmark1
 
The cost of building a new high speed railway system is reported to be.docx
The cost of building a new high speed railway system is reported to be.docxThe cost of building a new high speed railway system is reported to be.docx
The cost of building a new high speed railway system is reported to be.docxlmark1
 
The condition of a system as descriked by its properties A macroscopic.docx
The condition of a system as descriked by its properties A macroscopic.docxThe condition of a system as descriked by its properties A macroscopic.docx
The condition of a system as descriked by its properties A macroscopic.docxlmark1
 
The concept of the accounting entity is considered by some to be the m.docx
The concept of the accounting entity is considered by some to be the m.docxThe concept of the accounting entity is considered by some to be the m.docx
The concept of the accounting entity is considered by some to be the m.docxlmark1
 
The computer revolution has altered the ways white-collar criminals co.docx
The computer revolution has altered the ways white-collar criminals co.docxThe computer revolution has altered the ways white-collar criminals co.docx
The computer revolution has altered the ways white-collar criminals co.docxlmark1
 
The computation of a safe installment payment for the XYZ partnership.docx
The computation of a safe installment payment for the XYZ partnership.docxThe computation of a safe installment payment for the XYZ partnership.docx
The computation of a safe installment payment for the XYZ partnership.docxlmark1
 
The component that connects a devices (a computer) to the communicatio.docx
The component that connects a devices (a computer) to the communicatio.docxThe component that connects a devices (a computer) to the communicatio.docx
The component that connects a devices (a computer) to the communicatio.docxlmark1
 
The CEO of US Xpress wants to meet with your team and have you provide.docx
The CEO of US Xpress wants to meet with your team and have you provide.docxThe CEO of US Xpress wants to meet with your team and have you provide.docx
The CEO of US Xpress wants to meet with your team and have you provide.docxlmark1
 
The case notes that Nationwide had in mind a simple goal- but faced a.docx
The case notes that Nationwide had in mind a simple goal- but faced a.docxThe case notes that Nationwide had in mind a simple goal- but faced a.docx
The case notes that Nationwide had in mind a simple goal- but faced a.docxlmark1
 
The capital budgeting analytical technique that calculates the rate of.docx
The capital budgeting analytical technique that calculates the rate of.docxThe capital budgeting analytical technique that calculates the rate of.docx
The capital budgeting analytical technique that calculates the rate of.docxlmark1
 
The balance sheet is the cornerstone of the financial statements- The.docx
The balance sheet is the cornerstone of the financial statements- The.docxThe balance sheet is the cornerstone of the financial statements- The.docx
The balance sheet is the cornerstone of the financial statements- The.docxlmark1
 
The capital account balances for Donald & Hanes LLP on January 1- 2011.docx
The capital account balances for Donald & Hanes LLP on January 1- 2011.docxThe capital account balances for Donald & Hanes LLP on January 1- 2011.docx
The capital account balances for Donald & Hanes LLP on January 1- 2011.docxlmark1
 
the bookkeeper of vitial inc has asked to assist him with preparation.docx
the bookkeeper of vitial inc has asked to assist him with preparation.docxthe bookkeeper of vitial inc has asked to assist him with preparation.docx
the bookkeeper of vitial inc has asked to assist him with preparation.docxlmark1
 
The balanced scorecard integrates financial and nonfinancial measures.docx
The balanced scorecard integrates financial and nonfinancial measures.docxThe balanced scorecard integrates financial and nonfinancial measures.docx
The balanced scorecard integrates financial and nonfinancial measures.docxlmark1
 
The balance sheet for the partnership of Nina- Pinta- and Santa Maria.docx
The balance sheet for the partnership of Nina- Pinta- and Santa Maria.docxThe balance sheet for the partnership of Nina- Pinta- and Santa Maria.docx
The balance sheet for the partnership of Nina- Pinta- and Santa Maria.docxlmark1
 
PAD601 Comment in detail on the events of each date 1880- 1881- 1883-.docx
PAD601 Comment in detail on the events of each date 1880- 1881- 1883-.docxPAD601 Comment in detail on the events of each date 1880- 1881- 1883-.docx
PAD601 Comment in detail on the events of each date 1880- 1881- 1883-.docxlmark1
 
P5- Use the financial information below to calculate and interpret the.docx
P5- Use the financial information below to calculate and interpret the.docxP5- Use the financial information below to calculate and interpret the.docx
P5- Use the financial information below to calculate and interpret the.docxlmark1
 
Pablo own small transportation firm in Latvia- His trucks delivers goo.docx
Pablo own small transportation firm in Latvia- His trucks delivers goo.docxPablo own small transportation firm in Latvia- His trucks delivers goo.docx
Pablo own small transportation firm in Latvia- His trucks delivers goo.docxlmark1
 
Over the past weeks we have been examining the inference process- big.docx
Over the past weeks we have been examining the inference process- big.docxOver the past weeks we have been examining the inference process- big.docx
Over the past weeks we have been examining the inference process- big.docxlmark1
 
Outline the role of the operating system and identify the features of.docx
Outline the role of the operating system and identify the features of.docxOutline the role of the operating system and identify the features of.docx
Outline the role of the operating system and identify the features of.docxlmark1
 

Plus de lmark1 (20)

The December 31- 2012- balance sheet for Thomas Company showed total s.docx
The December 31- 2012- balance sheet for Thomas Company showed total s.docxThe December 31- 2012- balance sheet for Thomas Company showed total s.docx
The December 31- 2012- balance sheet for Thomas Company showed total s.docx
 
The cost of building a new high speed railway system is reported to be.docx
The cost of building a new high speed railway system is reported to be.docxThe cost of building a new high speed railway system is reported to be.docx
The cost of building a new high speed railway system is reported to be.docx
 
The condition of a system as descriked by its properties A macroscopic.docx
The condition of a system as descriked by its properties A macroscopic.docxThe condition of a system as descriked by its properties A macroscopic.docx
The condition of a system as descriked by its properties A macroscopic.docx
 
The concept of the accounting entity is considered by some to be the m.docx
The concept of the accounting entity is considered by some to be the m.docxThe concept of the accounting entity is considered by some to be the m.docx
The concept of the accounting entity is considered by some to be the m.docx
 
The computer revolution has altered the ways white-collar criminals co.docx
The computer revolution has altered the ways white-collar criminals co.docxThe computer revolution has altered the ways white-collar criminals co.docx
The computer revolution has altered the ways white-collar criminals co.docx
 
The computation of a safe installment payment for the XYZ partnership.docx
The computation of a safe installment payment for the XYZ partnership.docxThe computation of a safe installment payment for the XYZ partnership.docx
The computation of a safe installment payment for the XYZ partnership.docx
 
The component that connects a devices (a computer) to the communicatio.docx
The component that connects a devices (a computer) to the communicatio.docxThe component that connects a devices (a computer) to the communicatio.docx
The component that connects a devices (a computer) to the communicatio.docx
 
The CEO of US Xpress wants to meet with your team and have you provide.docx
The CEO of US Xpress wants to meet with your team and have you provide.docxThe CEO of US Xpress wants to meet with your team and have you provide.docx
The CEO of US Xpress wants to meet with your team and have you provide.docx
 
The case notes that Nationwide had in mind a simple goal- but faced a.docx
The case notes that Nationwide had in mind a simple goal- but faced a.docxThe case notes that Nationwide had in mind a simple goal- but faced a.docx
The case notes that Nationwide had in mind a simple goal- but faced a.docx
 
The capital budgeting analytical technique that calculates the rate of.docx
The capital budgeting analytical technique that calculates the rate of.docxThe capital budgeting analytical technique that calculates the rate of.docx
The capital budgeting analytical technique that calculates the rate of.docx
 
The balance sheet is the cornerstone of the financial statements- The.docx
The balance sheet is the cornerstone of the financial statements- The.docxThe balance sheet is the cornerstone of the financial statements- The.docx
The balance sheet is the cornerstone of the financial statements- The.docx
 
The capital account balances for Donald & Hanes LLP on January 1- 2011.docx
The capital account balances for Donald & Hanes LLP on January 1- 2011.docxThe capital account balances for Donald & Hanes LLP on January 1- 2011.docx
The capital account balances for Donald & Hanes LLP on January 1- 2011.docx
 
the bookkeeper of vitial inc has asked to assist him with preparation.docx
the bookkeeper of vitial inc has asked to assist him with preparation.docxthe bookkeeper of vitial inc has asked to assist him with preparation.docx
the bookkeeper of vitial inc has asked to assist him with preparation.docx
 
The balanced scorecard integrates financial and nonfinancial measures.docx
The balanced scorecard integrates financial and nonfinancial measures.docxThe balanced scorecard integrates financial and nonfinancial measures.docx
The balanced scorecard integrates financial and nonfinancial measures.docx
 
The balance sheet for the partnership of Nina- Pinta- and Santa Maria.docx
The balance sheet for the partnership of Nina- Pinta- and Santa Maria.docxThe balance sheet for the partnership of Nina- Pinta- and Santa Maria.docx
The balance sheet for the partnership of Nina- Pinta- and Santa Maria.docx
 
PAD601 Comment in detail on the events of each date 1880- 1881- 1883-.docx
PAD601 Comment in detail on the events of each date 1880- 1881- 1883-.docxPAD601 Comment in detail on the events of each date 1880- 1881- 1883-.docx
PAD601 Comment in detail on the events of each date 1880- 1881- 1883-.docx
 
P5- Use the financial information below to calculate and interpret the.docx
P5- Use the financial information below to calculate and interpret the.docxP5- Use the financial information below to calculate and interpret the.docx
P5- Use the financial information below to calculate and interpret the.docx
 
Pablo own small transportation firm in Latvia- His trucks delivers goo.docx
Pablo own small transportation firm in Latvia- His trucks delivers goo.docxPablo own small transportation firm in Latvia- His trucks delivers goo.docx
Pablo own small transportation firm in Latvia- His trucks delivers goo.docx
 
Over the past weeks we have been examining the inference process- big.docx
Over the past weeks we have been examining the inference process- big.docxOver the past weeks we have been examining the inference process- big.docx
Over the past weeks we have been examining the inference process- big.docx
 
Outline the role of the operating system and identify the features of.docx
Outline the role of the operating system and identify the features of.docxOutline the role of the operating system and identify the features of.docx
Outline the role of the operating system and identify the features of.docx
 

Dernier

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
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
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
 
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
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
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
 
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
 
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
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
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
 

Dernier (20)

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
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.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
 
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.
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
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
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
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
 
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
 
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...
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
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
 

Palindromes A palindrome is a word or phrase that reads the same backw (2).docx

  • 1. Palindromes A palindrome is a word or phrase that reads the same backwards and forwards, ignoring punctuation, spaces, and anything that isn’t a letter. Examples of Palindromes Madam, I’m Adam. Kayak Racecar A man, a plan, a canal – Panama! Able was I, ere I saw Elba. C Program ONLY (Please not C++ or Java) I need to write a program that does the following: *USING STRINGS TO PERFORM THE FOLLOWING*: 1. opens a text file named “Lab12input.txt― containing multiple lines of text (.txt file has been provided already just need code to open .txt file) 2. for each line, print out “Palindrome:― and then the line of text if it IS a palindrome, and print out “Not a palindrome:― and the line of text if it is NOT a palindrome. Thanks! Solution int checkispallindrome(char* string) {
  • 2. int i; int l = strlen(string); for (i = 0; i < l / 2; i++) { if (string[i] != string[l - i - 1]) cout<<”not a palindrome”; } cout<<”it is a palindrome”; } int main() { FILE* f = fopen("myfile.txt", "r"); char string[10]; while(fscanf(f, "%s", string) > 0) { checkispallindrome(string; printf("%s ", string); } }