Menu
Question Index
...

Write a program to find the average of all numbers till a given number.

Input (Integer) Output (Integer)
7 (1 + 2 + 3 + 4 + 5 + 6 + 7) / 7 = 4
15 (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15) / 15 = 8



class Average
{
    public static void main(String s[])
    {
        System.out.println("Average of numbers till 5 is " + averageOfNumbers(5));

    }


    public static int averageOfNumbers(int input)
    {
        int output = 0;
        return output;
    }

}

Doubts

Problems

Topic: for Loop In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App