8.1.. Saberi parne prirodne brojeve do 100.

Opis programa:

Listing programa:

package Package2;
import java.util.Scanner;
public class P08111016 {

	private static Scanner input;
	public static void main(String[] args) {
		input = new Scanner(System.in);
		System.out.print("Saberi sve parne brojeve do 100");
		int suma = 0;
	
	    for(int i=1; i<=100; i++)
	    	if (i% 2==0)
	    	   suma = suma + i;
	    System.out.println("Od "+1+" do " +100+ " suma = " +suma);
		
}}

Ispis na ekranu:

Index