[Previous Homework] [Next Homework]

hw19 - Strings 2


Develop an interactive application in which the user enters a number less than 1000. Convert the number to the word representation of the value and print it out.

  • Structure your code according to the following:
    • getInput()
      • Read in integer value from the user
      • Return the integer value from the function
    • convertToString()
      • Work from left to right in the numeric sequence
      • Each place should have it have its own function
        • In each function, define an array of strings;
          • e.g., "one thousand", "two thousand",...
        • Use mathematical computation to get the digit in that place and save it as an integer value
        • Use that value as an index into the array of strings for that place
        • Return the string representation of that place as a char *
      • Concatenate the string value returned from that place into a string that holds the final result
      • Return the word sequence as a char *


From Linux on the GL machine:
  • Compile the program:
    gcc -o string2 string2.c

  • Run the program to make sure it works:
    ./string2

  • Use the SUBMIT utility turn in the homework.
    submit cs104_grasso hw19 string2.c string2


Reference Programs :



Make sure that you follow all the coding standards