Practice1 - triangle is equal to the square of its...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
German University in Cairo Faculty of Media Engineering and Technology Prof. Dr. Slim Abdennadher Introduction to Computer Science , Winter Term 2009-2010 Practice Assignment 1 Discussion: 10.10.2009 - 15.10.2009 Exercise 1-1 Write an algorithm to determine the ying time between two cities given the mileage between them and the average speed of the airplane. Exercise 1-2 Write an algorithm that calculates and prints the annual cost of running an appliance given the cost per kilowatt-hour in cents and the number of kilowatt-hours the appliance uses in a year. Exercise 1-3 Write an algorithm that given the width and length of a garden in meters calculates the area of the garden together with the number of trees that could be planted on this garden area, knowing that each tree needs a space of 50 cm 2 . Exercise 1-4 The Pythagorean Theorem states that the sum of the squares of the two sides of a right angle
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: triangle is equal to the square of its hypotenuse. For example, 3 , 4 and 5 are the sides of a right angle triangle as they form a Pythagorean Triple ( 5 2 = 4 2 +3 2 ). Given 2 numbers, m and n where m ≥ n , a Pythagorean Triple can be generated by the following formulae: a = m 2-n 2 b = 2 × m × n c = p a 2 + b 2 Write an algorithm that reads in values for m and n and prints the values of the Pythagorean Triple generated by the formulae above. Exercise 1-5 Write an algorithm that reads the amount of time in seconds and then displays the equivalent hours, minutes and seconds. Note: You can use the function INT(x/y) that gives the integer part of the result of the division x/y . For example INT(5/2)=2 . 1...
View Full Document

This note was uploaded on 12/22/2009 for the course CSEN 102 taught by Professor Slim during the Spring '09 term at German University in Cairo.

Ask a homework question - tutors are online