Thursday, May 10, 2012

Expression Evaluation: Sum & Average

Hello Guys!!! How are you ? Hope, you all are well by the grace of Almighty. Today we learn how to find out the sum and the average of some integer numbers. Let's look at the problem:

Problem:  Write a program that receives five integers and returns the sum and average of these numbers.

Solve:

Generally we know that, if five integers are a, b, c, d, & e,
their sum = (a+b+c+d+e) 
their average = (a+b+c+d+e) / 5
Now, we can write a c programming code by using this formula. Let's look at the program:
















In this code, in line no. 12, we can write any of this two: "avg=sum/5.0;" or, "avg=sum/(float)5;".

Thank you all..:)

0 comments:

Post a Comment