0% found this document useful (0 votes)
3 views1 page

Tutorial 2 2019

Uploaded by

Katlo Pilane
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)
3 views1 page

Tutorial 2 2019

Uploaded by

Katlo Pilane
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

Tutorial 2: C++ Basics

1) Write a program that reads in two numbers, calculates and print their total.

2) Write a program that reads in three numbers, calculates and print their product.

3) Write a program which prompts the user for a Celsius temperature, convert the

temperature to Fahrenheit and prints out the converted temperature.

4) Write a pseudocode that will allow a system user to enter five marks for a student.

The program must find the average of those marks and display it on the screen.

5) Write a program that prompts a user to enter a number, and determines if a

number is even or odd.

6) Consider the pseudocode below: Write a C++ program based on the pseudocode
below.
Use variables: years OF TYPE INTEGER
Use variables: sales, wage, loyaltyBonus OF TYPE REAL
Use variable: salesmanName OF TYPE STRING
Begin
DISPLAY “Please enter the name of a salesman”
ACCEPT salesmanName
DISPLAY “Please enter sales for this period”
ACCEPT sales
DISPLAY “Please enter number of years he has spent in this
company”
ACCEPT years
wage := sales * 0.15
loyaltyBonus:= wage * 0.1
IF years > 3
THEN wage:= wage + loyaltyBonus
ENDIF
DISPLAY salesmanName “earns” wage

You might also like