SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
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
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 

Kürzlich hochgeladen (20)

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
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
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 

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