8.3.. Saberi parne prirodne brojeve do 100.
Opis rješenja:
Opis programa:
Listing programa :
package zadatak;
import java.util.Scanner;
public class 08311016
{
public static void main(String[] args)
{
Scanner input = new Scanner (System.in);
int i=1;
double s=0;
do
{
if (i%2==0)
s=s+i;
i++;
} while (i<=100);
System.out.println("Suma parnih brojeva do 100 je: " + s);
}
}
Ispis na ekranu:
Index
|