Você está na página 1de 4

Faculty of Computer & Informatics

Section_1
Fundamental of Structured Programming
Lab Handout Questions First Year 2/19/2012

EXERCISE 1
Write a program that asks the user to type the width and the length of a rectangle and then outputs to the screen the area and the perimeter of that rectangle.

EXERCISE 2
Write a program that asks the user to type 5 integers and writes the average of the 5 integers. This program can use only 2 variables.

EXERCISE 3
Write a program that asks the user to type 2 integers A and B and exchange the value of A and B.

EXERCISE 4
Write a program that asks the user to type the coordinate of 2 points, A and B (in a plane), and then writes the distance between A and B.

EXERCISE 5
Write a C++ program to accept from the user 3 marks for a student out of 100 and outputs whether the student passed or failed. The passing grade for each subject is 40. The student passes if he passes in all three subjects, moreover the student also passes if he fails in only one subject but the average of his grades is greater than or equal to 50. Otherwise the student fails. Enter the grades: 35 60 75 The student passed.

2|Page

EXERCISE 6
Write a program that takes two arguments (x and y) and one operator (+, *, - , /) and returns only one result. (Use switch case)

EXERCISE 7
Write a program that asks the user to enter two numbers and check if they are a multiple or not.

EXERCISE 8
Write a program that asks the user to type 2 integers and check if them are positive, negative, even or odd.

EXERCISE 9
Write a program that asks the user to enter three integers A and B and return the smallest and largest number on them.

EXERCISE 10
Write a program that calculates the area of a circle whose radius is supplied by the user.

EXERCISE 11
Write a program that asks the user for a lowercase letter of the alphabet and then prints its equivalent uppercase letter.

3|Page

EXERCISE 12 (H.W.)
Write an encrypting program that converts each character received into the next character in the alphabet. As a special case, convert z into a.

EXERCISE 13 (H.W.)
Write a program that neatly prints a table of powerssquares and cubes. Print these powers for the integers from 1 to 100. The first few lines of the table might appear as follows:

integer 1 2 ..

square 1 4 ..

cube 1 8 ..

4|Page

Você também pode gostar