CS126-8L: Computer Programming 1 (Laboratory) : Directions
CS126-8L: Computer Programming 1 (Laboratory) : Directions
CS126-8L: Computer Programming 1 (Laboratory) : Directions
Directions:
1. For each solution, you need to put on the following program comment indicating the
problem number, your name, today’s date, program, course/section and the purpose of
the program.
Example: /*
* Programmer: FUENTES, Gloren S.
* Date Created: 10/14/2020
* Program: BSCS/BMCS/BSIT/BMIT
* Course / Section: CS126-8L/OL160
* Purpose: This program will calculate the speed from distance over time.
(or copy and paste the given problem)
*/
2. Save your code in CPP format with the filename: FLNAME-PRAC02.cpp (e.g.
GFUENTES-PRAC02.cpp)
3. Once done, upload your file on Blackboard.
4. Failure to follow instructions will get a 5-point deduction. Please be guided accordingly.
1. Create C++ program for the following: (In implementing your program, use any function
declaration for each problem and combine them in one program)
MENU OPTIONS:
[1] Sum of Integer Numbers
[2] Ribbon
[3] Highest and Lowest Odd and Even Random Numbers
Enter your choice: _
𝑛(𝑎1 +𝑎𝑛 )
The formula for calculating the sum is: 𝑠𝑢𝑚 =
2
Sample Output 1:
Input the first number to be added (a1): 1
Input the last number to be added (an): 12
The sum of 1 to 12 = 78
Sample Output 2:
Input the first number to be added (a1): 88
Input the last number to be added (an): 95
The sum of 88 to 95 = 732
[2] Create a UDF (no return /no passing parameter) will prompt the user to input the
size of ribbon figure (5-15) odd numbers only and display the figure like this:
Sample Output:
Input size of Ribbon to generate (5-15) odd numbers only: 5
# #
# # # #
# # # # #
# # # #
# #
[3] Create a UDF (no return /with passing parameter) that prompts the user to input
how many random numbers to generate in the range of -100 to 100. Valid input is from
1-100. Output how many positive numbers generated and the highest and lowest among
the positive numbers. Output also how many negative numbers generated and the highest
and lowest among the negative numbers.
Sample Output:
Random numbers to generate (-100 to 100 only): 10