COSC 122 - Computer Fluency
Programming Practice Questions


I strongly encourage you to attempt one or more of these practice programming questions. A short description is provided. Then a link to the code so that you can try it. Make sure to try answer the question before you look at the answer!


Prompts, Document Output, If statement, String Concatenation

  1. Adder - Prompt the user for two numbers. Then ask for either an 'A' or an 'S'. If it is an 'A', add the two numbers and show the answer. If it is an 'S', subtract the two numbers. Otherwise, insult their ability to follow directions!
  2. Name Scrambler - Prompt the user for two first names and last names. Output them mixed up with the first name one with last name two and first name two with last name one.
  3. Mark Commentator - Prompt the user for their expected number grade in this course and the current overall grade average. Insult or praise them depending on their performance.

For Loops and Arrays

  1. Stars - Print a line of N stars, where the user enters the number N.
  2. Stars and Stripes - Print a line of N stars and N-1 stripes, where the user enters the number N.
  3. Annoying Prompter - Prompt the user for the number of prompts. Store all user answers in an array. Print out all the user responses in backwards order. The user can stop before the number entered by saying 'STOP'.
  4. Smallest Name - Prompt the user for a number of names. Ask the user for each name and store them in the array. Print the smallest name. Then print every second name in the array.
  5. Color Count by Threes - Count from 0 to 30 by threes. Print out each number on a new line, with every number divisible by 6 coloured blue, and any others coloured red. Answers: Color Count by Threes (using loop to 30), Color Count by Threes (better way)

HTML Forms

  1. Form validation - Given the HTML form, check that the fields are filled in with a value. Give the user an alert saying which field of the form is empty, or a message saying that their message has been sent if all fields are filled in. You can either have only the first empty field displayed to the user, or for a bigger challenge alert the user to all empty fields in one message (This can be done with or without an array). Basic Form Answers: Output First Error Message, Output All Errors (no array), Output All Errors (array version)

*Home