Computer Science, asked by Anonymous, 4 hours ago

wap a program using while loop to calculate the sum of first 10 even and odd integers.
(brainlyprogrammer, copythat, anindyaadhikari13)

Answers

Answered by BrainlyProgrammer
7

Answer:

//Solved in Java

class sum{

public static void main (String ar []){

int s=0,S1=0;

for(int I=1;I<=20;I++){

s+=(i%2==0)?I:0;

S1+=(i%2!=0)?I:0;

}

System.out.println("Sum of even="+s+"\nSum of Odd"+S1);

}

}

Similar questions