Tuesday, March 18, 2008

average of 3 numbers

/* Program to calculate average of 3 numbers */

class P1
{
public static void main(String args[])
{
int a, b, c, average;
a = 3;
b = 7;
c = 2 ;
average = ( a + b + c ) / 3;
System.out.println(" Average : "+average);
}
}

5 comments:

Thuzitha Nuwan B. said...

Thank u very much Mr. Yogendra. This was helpful for me very much. Thumbz up. Keep posting type of small programme codes. It's a good help for beginners. Thanx again buddy. TC

Unknown said...

I have a question.
what would happen if we write as
double avg=(a+b+c)/3.0;

Unknown said...

i also want to know the same... divison is involved so why double will not come

Unknown said...

thanku for help

Unknown said...

thanku very much yogedra ধন্যবাদ