8.2.. Saberi parne prirodne brojeve do 100.

Opis rješenja:

Opis programa:

Listing programa :

package zadatak;
import java.util.Scanner;
public class 08211016 
{

	public static void main(String[] args)
	{
	Scanner input = new Scanner (System.in);
	int i=1;
	double s=0;
	while (i<=100)
	{
	if (i%2==0)
	{
	s=s+i;
	}
	i++;
	}
	System.out.println("Suma parnih brojeva do 100 je: " + s);
	}
}

Ispis na ekranu:

Index