Introduction to Computer Science - Fall 2010
CSCI 151
SWITCH STATEMENT AND CHAR TYPE LECTURE PRACTICE
  

  • Program 1: Write a program that reads a sequence of 10 characters and prints the ASCII value for each character and finds the number of characters that are equal '*'.

  • Program 2: Write a program that reads a sequence of characters, character '%' will terminate the input. finds the number of lower case letters, the number of upper case letters, and the number of digits.

  • Program 3 :
    USE SWITCH in this program.
    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 10 integer numbers and the program will find the maximum and the minimum among the inputs, 2 - program asks the user to enter the integer and checks if the input number even or odd, 3 - program prints all two-digit numbers divisible by the sum of their digits

  • Problem 4
    Use SWITCH in this program
    Write a program that prompts the user to enter one character. You have to use switch statement in your program in order to do the following: if the input character is 'b', the program reads one number of type double and prints this number 5 times on one line, numbers should be separated by tab. (you should use loop to do it); if the input character is 'd', the program prints the following rectangle:
    aaabbb
    bbbaaa
    aaabbb
    bbbaaa
    aaabbb
    bbbaaa
    you have to use loop to do this (TRY TO MAKE IT AS SHORT AS POSSIBLE), and if the input character is 'p', the program will find the product of all odd numbers between 1 and 15 (including 15) ( you should use loop in this part); if the input character is not 'b', 'd' or 'p', the program will print the input character 5 times on different lines (you should use loop to do it).