Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

ENG2139 C++ PROGRAMMING LAB ONE (2023)

TOTAL TIME: 3 HOURS

1. Write a program that lets the user enter the total rainfall for each of 12 months into an
array of doubles. The program should calculate and display the total rainfall for the year,
the average monthly rainfall, and the months with the highest and lowest amounts. Input
Validation: Do not accept negative numbers for monthly rainfall figures.
2. In a program, write a function that accepts three arguments: an array, the size of the
array, and a number n. Assume that the array contains integers. The function should
display all of the numbers in the array that are greater than the number n.
3. Imagine you are developing a software package that requires users to enter their own
passwords. Your software requires that users’ passwords meet the following criteria:
a. The password should be at least six characters long.
b. The password should contain at least one uppercase and at least one lowercase
letter.
c. The password should have at least one digit.
Write a program that asks for a password and then verifies that it meets the stated criteria.
If it doesn’t, the program should display a message telling the user why.
4. Write a function that accepts a pointer to a C-string as an argument and returns the
number of words contained in the string. For instance, if the string argument is “Four
score and seven years ago” the function should return the number 6. Demonstrate the
function in a program that asks the user to input a string and then passes it to the function.
The number of words in the string should be displayed on the screen.

NOTE:
*will send the format of the report later

You might also like