package com.itheima;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;
/*
求100以内奇数的和
/
public class forDemo05 {
public static void main(String[] args) {
/ //定义初始化变量
int i = 1;
int sum = 0;
//判断i是否小于100
while (i <= 100) {
//判断i是否是奇数
if (i % 2 == 1) {
//奇数求和
sum += i;
}
//条件控制语句
i++;
}
System.out.println("100以内的奇数和是:" + sum);*/
//定义初始化变量
int i = 1;
int sum = 0;
//判断i是否小于100
while (i <= 100) {
//奇数求和
sum += i;
i += 2;//1 3 5 7 9 11..99 101
}
System.out.println("100以内的奇数和是:" + sum);
}
}