Question 1: Perfect Numbers

Develop a program to find and print the first 5 perfect numbers. A perfect number is a positive integer that is equal to the sum of all the positive integers (except itself) that divide it evenly. For example, the number 6 is a perfect number because the integers that divide it evently are : 1,2,3, and 6. Thus, 6 is the sum of its divisors, except for 6 itself. Finding the first 3 perfect numbers is easy. Finding the last two can take time (unless you use math theory, use a book from library). If you find 4, you will get full marks, If you find 5, you will get a bonus mark.

* Define the variable as : unsigned long your_variable_name;
* Print the numbers as  : fprintf("%lu",your_variable_name);

Question 2: Valid Triangles



Question 2: Valid Triangles

You are given eight sets of three values each:

          23.37   19.51   8.37
          57.46   40.06   27.57
          42.09   35.78   61.65
          8.63    15.74   12.38
          61.94   78.07   10.87
          19.56   23.54   33.28
          84.37   61.98   15.93
          37.80   49.24   23.51

Write a C program to determine if the three values of a set could represent the lengths of the sides of a triangle. If the three sides could make a triangle, calculate its area and print a message like:

          When AB=3.00 and BC=4.00 and CA=5.00,
          the area of triangle ABC is 6.00

If a, b, c are three side lengths, then the area is

SQRT( (s(s-a)(s-b)(s-c)) )

where s is the half perimeter (a+b+c)/2

(the formula is due to Hero, a mathematician of ancient times.)

If the three values in a set could not represent the sides of a triangle, print a message like:

       23.37, 19.51, and 9.37 could not possibly be the sides of a triangle.

A property of Hero's formula: if s(s-a)(s-b)(s-c) is negative, then a, b, c can't make a triangle.

Please MAKE SURE YOU PUT your name, student #, and assignment #. Also, put some comments on your code so that the grader can figure out what you are doing. It helps to have meaningful variable name, like AREA instead of X for a variable containing an area value.



Instructor Code - CS208
Thu Mar 5 13:26:48 EST 1998