Menu
Question Index
...

Write a program to find the sum of all integers till a given number.

Input (Integer) Output (Integer)
7 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28
3 1 + 2 + 3 = 6



class SumOfIntegersTillGivenNumber
{
    public static void main(String s[])
    {
        System.out.println("Sum of all integers till 5 is " + sum_of_numbers(5));

    }


    public static int sum_of_numbers(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