Responses to programming challenges at Cprogramming.com
- Challenge 1 Array input and output: When completed, the following program should first fill in (by asking the user for input) and then list all the elements in an array
- Challenge 2 Guessing Game: Act as a guessing game in which the user has eight tries to guess a randomly generated number. The program will tell the user each time whether he guessed high or low
- Challenge 3 Calculator: Act as a basic calculator; it should ask the user to input what type of arithmetic operation he would like, and then ask for the numbers on which the operation should be performed. The calculator should then give the output of the operation.
- Challenge 4 Temperature Converter: write a program that takes in three arguments, a start temperature (in Celsius), an end temperature (in Celsius) and a step size. Print out a table that goes from the start temperature to the end temperature, in steps of the step size; you do not actually need to print the final end temperature if the step size does not exactly match. You should perform input validation: do not accept start temperatures less than a lower limit (which your code should specify as a constant) or higher than an upper limit (which your code should also specify). You should not allow a step size greater than the difference in temperatures.
- Challenge 5 Line Count Challenge: write a program that takes a file as an argument and counts the total number of lines. Lines are defined as ending with a newline character.
Program usage should be
count filename.txt
And the output should be the line count. - Challenge 6 File Size Challenge: determine the size of a file. Given the name of a file, print out the size of the file, in bytes. If no file is given, provide a help string to the user that indicates how to use the program.
- Challenge 7 String Permutation Challenge: Here is another mathematical problem, where the trick is as much to discover the algorithm as it is to write the code: write a program to display all possible permutations of a given input string--if the string contains duplicate characters, you may have multiple repeated results.
Input should be of the form
permute string
and output should be a word per line. Here is a sample for the input catcat cta act atc tac tca