+ 1
Can anyone help me please.
Write java program to input 100 integer number and print the addition of it
7 Answers
+ 5
import java.util.Scanner;
public class addition
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter 100 integer number:");
int n, sum = 0;
for(int i = 1; i<=100; i++) {
n = sc.nextInt();
sum = sum+n;
}
System.out.println(sum);
}
}
Here is right one! Actually mistake was in {} and ,
+ 4
Rishabh Bhai, first show your attempts!
+ 4
You can the input and print statements execute in for loop.
+ 2
thank you bhai
+ 1
Wait i am just doing and posting it
0
import java.util.Scanner;
public class addition
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter 100 integer number:");
int n; sum = 0;
{
for(int i = 1; i<=100; i++)
n = sc.nextInt();
sum = sum+n;
}
System.out.println(sum);
}
}
0
Brother i have written this