❶ 編寫java程序,分別應用while語句、do-while語句,求出100以內所有奇數的和
whileint i=1;
int result=0;
while(i<=100){
result+=i;
i+=2;
}
System.out.println("100內奇數和為:"+result);
do{}while{}
int i=1;
int result=0;
do {
result+=i;
i+=2;
}while (i<=100);
System.out.println("100內奇數和為:"+result);