On 10/28/07, 洪海昆 <[EMAIL PROTECTED]> wrote:

> #include<stdio.h>
> int main ()
> {
>  int x,total=0;
>  for (x=100 ;x<=150;x++)
>  total+=x;
>  return 0;
> }
>
>
> i want to get the sum of 100~150.but the programming doesn't wok.

I think you'd want to print out the total when you are done. You
should indent your code a little better also, to make it easier to
read.

#include<stdio.h>

int main () {
 int x, total=0;

 for (x=100; x <= 150; x++)
   total += x;

 printf("sum = %d", total);

 return 0;
}

I get sum = 6375 when I run this.

-- Brett
------------------------------------------------------------
"In the rhythm of music a secret is hidden;
    If I were to divulge it, it would overturn the world."
               -- Jelaleddin Rumi

Reply via email to