0% found this document useful (0 votes)
95 views2 pages

CS126 8L Practical2

This document provides instructions for a practical exam assignment in a computer programming lab course. Students are to create a C++ program with a menu that allows the user to choose between printing prime numbers, a multiplication table, or exiting. The prime number program takes a user input for how many primes to generate and prints that many primes. The multiplication table program takes a user input for the table size and prints the corresponding multiplication table. Both programs ask the user if they want to return to the menu or terminate after running.

Uploaded by

Sashza Jeon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
95 views2 pages

CS126 8L Practical2

This document provides instructions for a practical exam assignment in a computer programming lab course. Students are to create a C++ program with a menu that allows the user to choose between printing prime numbers, a multiplication table, or exiting. The prime number program takes a user input for how many primes to generate and prints that many primes. The multiplication table program takes a user input for the table size and prints the corresponding multiplication table. Both programs ask the user if they want to return to the menu or terminate after running.

Uploaded by

Sashza Jeon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CS126-8L: Computer Programming 1 (Laboratory)

Directions:

1. Use C++ compiler to create your program. (preferably Bloodshed Dev C++ or
https://www.onlinegdb.com/online_c++_compiler)
2. Save your code in CPP format with the filename: FLNAME-PRACTICAL2.cpp (e.g.
GFUENTES-PRACTICAL2.cpp)
3. Once done, upload your file on Blackboard.
4. Failure to follow instructions will get a 5-point deduction. Please be guided accordingly.

Practical Exam# 2 (100 points total)

[1] Create a C++ program that will show the user the following and enter his/her choice:

**************MENU**************
[1] PRIME NUMBER
[2] MULTIPLICATION TABLE
[3] EXIT
*********************************
ENTER YOUR CHOICE: _

***Every valid choice should have system(“cls”) after taking the input.

[1] Create a C++ program that would input a number and output the series of prime
numbers. A prime number is a number with a factor of one and only itself.

Examples of Prime Numbers are: 2, 3, 5, 7, 11, 13, 17, 19, 23, etc.

Sample Output:
How many prime numbers would you like to generate (1 – 100)? 5
The first 5 prime numbers are:
2 3 5 7 11
Return to Main Menu? [Y/N]: _

***If Y then go back to the menu. If N, then terminate the program.


[2] Create a C++ program that will ask the user the size of the multiplication table and
display it corresponding output on screen.
Sample Output:
Enter the size of Multiplication Table (1 to 10 only):

The 5 by 5 multiplication table:

1 2 3 4 5 6 7 8 9 10

1 1 2 3 4 5 6 7 8 9 10
2 2 4 6 8 10 12 14 16 18 20
3 3 6 9 12 15 18 21 24 27 30
4 4 8 12 16 20 24 28 32 36 40
5 5 10 15 20 25 30 35 40 45 50
Return to Main Menu? [Y/N]: _

***If Y then go back to the menu. If N, then terminate the program.

***If Y then go back to the menu. If N, then terminate the program.

Hint: Use Switch Case Statement for the choices in the Main Menu. Use Do-While
Statement and Continue Statement to validate the choices of 1-3 and Y/N.

You might also like