LAB02

advertisement
CS110 Lab 2
Due by Tuesday, Oct 8, 2013
This lab assignment will require you to write three programs in C++.
Goals:
-
To write simple decision-making statements in C++.
To use the if and if...else selection statements to choose among alternative actions.
To use the while repetition statement to execute statements in a program repeatedly.
Counter-controlled repetition and sentinel-controlled repetition.
To use the increment, decrement and assignment operators.
Your programs are graded on both correctness and style. Please review the comments regarding
programming style on the main page.
1. Write her/his gender 'Male' or 'Female'.
Write a complete c++ program that asks user to enter 'M' or 'F' and print his/her gender 'Male' or
'Female'.
As shown below
This program is identifying the
gender of the user.
What is your gender (M/F) ? F
You are Female!
2. Print (sum , product, difference and quotient)
Write a program that asks the user to enter two numbers, obtains the two numbers from the user and
prints the sum, product, difference, and quotient of the two numbers.
As shown below:
This program is using 4 operations on two
numbers entered by the user
Please enter num1
10
Please enter num2
4
The sum of num1 and num2 is 14.
The product of num1 and num2 is 40.
The difference of num1 and num2 is 6.
The quotient of num1 and num2 is 2.5.
3. find the two largest values among the 6 numbers
As shown below:
This program is comparing between six numbers entered by the
user and then prints the two largest numbers.
Please enter SIX numbers:
Enter num1 3
Enter num2 10
Enter num3 7
Enter num4 29
Enter num5 32
Enter num6 100
The two largest number are 32 and 100
Submit
Once you are satisfied with your programs, Save them in your document that has your name. and send it to
me by Oct 15.
NOTE
You will loss marks for late submission .
Grade
This Lab worth 10 marks 8 for correctness and 2 for style.
BEST WISHES ☺☺
NISREEN ALZAHRANI
Download