[TUHS] A c program problem

Caipenghui Caipenghui_c at 163.com
Thu Aug 23 01:46:58 AEST 2018


On August 22, 2018 11:40:18 PM GMT+08:00, Toby Thain <toby at telegraphics.com.au> wrote:
> On 2018-08-22 10:29 AM, cc wrote:
> > I want to figure out if the book is right or the compiler is right.
> > 
> > 	
> > cc
> 
> 
> Donald and Dan identified the issue in earlier replies.
> 
> $ cc foo.c -o foo
> $ ./foo
> 5050
> $ cat foo.c
> #include <stdio.h>
> int main(void)
> {
>        int i, sum = 0;
>        i = 1;
>        while ( i <= 100) {
>        sum = sum + i;
>        i++;
>        }
>        printf("%d\n", sum);
>        return 0;
> }
> 
> --Toby

Thank you very much for pointing this out, and I'm thrilled. Thank you for your kind help.




More information about the TUHS mailing list