8.1.. Saberi prirodne brojeve do 100.
Opis rješenja:
Opis programa:
Listing programa:
package Package2;
import java.util.Scanner;
public class P08111015 {
private static Scanner input;
public static void main(String[] args) {
input = new Scanner(System.in);
System.out.print("Saberi sve prirodne brojeve do 100"
);
int suma = 0;
for(int i=1; i<=100; i++)
suma = suma + i;
System.out.println("Od "+1+" do " +100+ " suma = " +suma);
}}
Ispis na ekranu:
Index
|