While Loop
/*
While Loop
B10234567 xxx
*/
main()
{
int a,b,sum=0;
printf("請輸入初始值:");
scanf("%d",&a);
printf("請輸入級數:");
scanf("%d",&b);
while (a<=100)
{
sum=sum+b;
a=a+b;
}
printf("和為%d\n",sum);
system("pause");
}
留言
張貼留言