Introduction to Computer Science - Fall 2009
CSCI 151
Lab 12
  

Objectives:
loops WHILE and FOR, SWITCH statement, char, int, float and double type
compiling and executing C code.   
Lab 12 includes Lab ASSIGNMENT ONLY
  1. Change to your CSCI151 directory: cd CSCI151
  2. Create a new directory lab12 under your CSCI151 directory: mkdir lab12
  3. Change to lab12 directory: cd lab12

    Lab Assignment

  4. Program 1 (50 points): Write a program that reads a character and an integer. The program prints the square of the character. The amount of rows and columns of the square equals to the input integer. For example, if the input:
    a 3
    The output should be:
    aaa
    aaa
    aaa
    Compile and Run your program. Show me the result and submit printout

  5. Program 2 (50 points):
    Write a C program menu.c that will print the program menu. The program prompts the user to enter one integer number, this number will be used in the program to indicate the specific menu choice. You should consider the following choices: input 0 - exit from the menu, 1 - program asks the user to enter year of birth and calculate and print the age of the user, 2 - program asks the user to enter the integer and determines and prints the sum of the even divisors, 3 - program asks the user to enter three float numbers and determines and prints the maximum between them. Show me the result.

    BONUS QUESTIONS. EACH QUESTION 10 points

  6. Program 1: Write a program that reads a sequence of characters, '$' will terminate the input. Program prints the ASCII value for each character and finds the number of characters that are equal 'Z'. Compile and Run your program. Show me the result. Submit the printout

  7. Program 2 : Write a C program menu.c that will print the program menu. The program prompts the user to enter one integer number, this number will be used in the program to indicate the specific menu choice. You should consider the following choices: input 0 - exit from the menu; 1 - program asks the user to enter a character and an integer, the program print the right triangle of the ASCII value of the character with the amount of rows equals to the input number; 2 - program asks the user to enter the integer and checks if the input number is prime or not, 3 - program asks the user to enter one character, one integer, and one real number. The program prints the square that consists of amount of rows that equal to the input integer. On each row the prgram will print real number first, and character next, and real number again, and so on. The total amount of real numbers and characters will be equal to the input integer. If the input number is zero or negative, the program will prints the error message.
    Example:
    If the menu choice is 1 and the input character is B and the input numbers is 5 the program prints
    66
    66 66
    66 66 66
    66 66 66 66
    66 66 66 66 66


    If the menu choice is 3 and the input is C, 5, 1.5
    The program prints:
    1.5 C 1.5 C 1.5
    1.5 C 1.5 C 1.5
    1.5 C 1.5 C 1.5
    1.5 C 1.5 C 1.5
    1.5 C 1.5 C 1.5
    Compile the program and show me the result.

  8. Program 3 : Write a program which will find and display all two-digit positive integers that are divisible by the sum of their digits.