Lab Sessions & Home Works: COSC221: Programming I Spring 2010 Prepared by Instructor: Ms. Maarouf
Lab Sessions & Home Works: COSC221: Programming I Spring 2010 Prepared by Instructor: Ms. Maarouf
Spring 2010
Prepared by Instructor: Ms. Maarouf
Exercises
1. Write a C++ program that asks the user to enter 10 prices and displays only the
prices that are greater than the average.
2. Write a program that asks the user to type 10 integers of an array and an integer
V. The program must search if V is in the array of 10 integers. The program
writes "V is in the array" or "V is not in the array".
3. Write a program that asks the user to type 10 integers of an array. The program
must write the index of the greatest element of the array.
5. Write a C++ program (using array) that read an integer and determines and prints
how many times each digit from 0 to 9 appears in the integer; i.e. frequencies. The
program should print the digit and its corresponding frequency only if that digit
occurred one or more times in the number.
6. Write a program that reads 20 integers from the user and store them in an array.
After reading the numbers, the program should display a menu to the user that
says:
The program should read the user choice and respond appropriately. For invalid
choices, error message should be displayed. The program should exit on g or G.
Make sure your program works for both cases.
7. Write a C++ program that creates an array using an initializing list. The array
should stores the letters of your name. Then your program should prompt a
character form the user and check if it exists in the array or not and display an
appropriate message. The program should ask the user until he/she enter “!”.