CSCI 1312 (Introduction to Programming for Engineering), Fall 2018:
Homework 8

Credit:
20 points.

Reading

Be sure you have read (or at least skimmed) the assigned readings from chapter 11.

Programming Problems

Do the following programming problems. You will end up with at least one code file per problem. Submit your program source (and any other needed files) by sending mail to bmassing@cs.trinity.edu with each file as an attachment. Please use a subject line that mentions the course and the assignment (e.g., ``csci 1312 hw 8'' or ``CS1 hw 8''). You can develop your programs on any system that provides the needed functionality, but I will test them on one of the department's Linux machines, so you should probably make sure they work in that environment before turning them in.

  1. (20 points) Write a complete C program that prompts the user for a single line of text and prints whether it is a palindrome, i.e., whether it's ``the same'' backwards as forwards, according to the following rules: The program should also print an error message if the text supplied by the user doesn't fit into the array you use to represent the input string.

    Here are some sample executions (assuming you call your program palindrome and compile with make):

    [bmassing@dias04]$ ./palindrome
    enter a line of text:
    abcd dcba
    input 'abcd dcba'
    a palindrome
    
    [bmassing@dias04]$ ./palindrome
    A man, a plan, a canal -- Panama!
    input 'A man, a plan, a canal -- Panama!'
    a palindrome
    
    [bmassing@dias04]$ ./palindrome
    enter a line of text:
    abcd 12 bcda
    input 'abcd 12 dcba'
    not a palindrome
    
    [bmassing@dias04]$ ./palindrome
    enter a line of text:
    abcd 1221 dcba
    input 'abcd 1221 dcba'
    a palindrome
    

    Hints:

Honor Code Statement

Include the Honor Code pledge or just the word ``pledged'', plus at least one of the following about collaboration and help (as many as apply).1Text in italics is explanatory or something for you to fill in. For programming assignments, this should go in the body of the e-mail or in a plain-text file honor-code.txt (no word-processor files please).

Essay

Include a brief essay (a sentence or two is fine, though you can write as much as you like) telling me what about the assignment you found interesting, difficult, or otherwise noteworthy. For programming assignments, it should go in the body of the e-mail or in a plain-text file essay.txt (no word-processor files please).



Footnotes

... apply).1
Credit where credit is due: I based the wording of this list on a posting to a SIGCSE mailing list. SIGCSE is the ACM's Special Interest Group on CS Education.


Berna Massingill
2018-11-02