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

Cairo University

Computer Engineering Department


Faculty of Engineering

CMPS102 - Programming Techniques


Graded Lab 1
For this lab, you are given a set of problems. Your task is to write code for each
problem to read the user input and produce the required output.
Please have all the codes under 1 solution, each in its own project.
Please make sure to test your code on different inputs and test cases.
Try to think of the possible values the inputs could take.
Make sure to handle any edge cases that might lead to runtime or logical errors.
Make sure your code is tested, and ready before delivering it to the TA.

1. Read a number from the user. Find the sum of numbers from 1 till the
given number.

Input
10
Output
The sum of numbers from 1 to 10 is: 55
Input
30
Output
The sum of numbers from 1 to 30 is: 465

2. Read a number from the user .Find the counts of multiples of 3 from 1
till the given number.

Input
10
Output
Count of multiples of 3 from 1 to 10 is 3

Page 1 of 2
Cairo University
Computer Engineering Department
Faculty of Engineering

3. Write a program containing a loop, in each iteration read a positive


number from the user and calculate the sum of even numbers.
The loop ends when the user enters 0.
Use Switch Case to answer this question

Input
5
6
2
10
9
11
0
Output
Sum of even numbers is 18

4. Write a program to find the area of a trapezium. Read from the user
the length of base 1, base 2 and height as float numbers and print the
area using the given formula.
Area= 0.5 *(base 1 + base 2)* height
Input
3.5 9 5.5
Output
Area of trapezium is 34.375

Page 2 of 2

You might also like