Objectives: Use While/for/do-While Loops. Use Switch Statements

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Yarmouk University

Hijjawi Faculty for Engineering Technology


Computer Engineering Department
CPE 150: Introduction to Programming Laboratory
Task # 04
Switch statement and Loops

Objectives
Use while/for/do-while loops.
Use switch statements.

Required Tasks:
1- Write a program that accepts the number of the day of the week and displays the
name of the corresponding day. Assume Day 1 is Saturday; Day 2 is Monday, and so
on. For example if you have entered 1 as your day number, the program should
display "The day is Saturday." as the output (Use switch statement to solve the
problem).

*******************************************************
Please insert the number of the day:
1

The day is Saturday


*******************************************************
2- Write a C++ program to print all numbers of an interval [N, M], where N and M
are integer numbers read from the keyboard (NM).

If wrong interval was entered, the following message should appear:


3- Write a program that reads a nonnegative integer and computes and prints its
factorial. The factorial of a nonnegative integer n is written n! .and defined as
follows:

Good Luck

You might also like