0% found this document useful (0 votes)
15 views

Lab Sessions & Home Works: COSC221: Programming I Spring 2010 Prepared by Instructor: Ms. Maarouf

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Lab Sessions & Home Works: COSC221: Programming I Spring 2010 Prepared by Instructor: Ms. Maarouf

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

COSC221: Programming I

Spring 2010
Prepared by Instructor: Ms. Maarouf

Lab Sessions & Home Works


2-hours Lab Sessions will be held every Friday 10:00-12:00 or 12:00-2:00.
During the lab sessions, students are being helped by the instructor and a senior teaching
assistant.
During the week that follows every lab session, students are asked to show the
teacher a demo of all the lab exercises on their laptops.

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.

4. Write a program which stores 2 arrays of 10 integers each, a and b. c is an array


with 20 integers. The program should first populate the two arrays a and b from
the user and then it should put into c the appending of b to a, the first 10 integers
of c from array a, the latter 10 from b. Then the program should display c.

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:

a. To display maximum value, please press a


b. To display minimum value, please press b
c. To display the average value, please press c
d. To display the even numbers, please press d
e. To display multiples of 7, please press e
f. To display all numbers, please press f
g. To exit, please press g

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 “!”.

You might also like