[ create a new paste ] login | about

Link: http://codepad.org/UxEw6pFU    [ raw code | output | fork ]

blaxjax - C, pasted on Sep 29:
#include <stdio.h>


int main(void)      {

    int count,sum,square;           
    int upto=10;                 

    count = 0;                
    square = 0;                 

    while (++count < upto)   {   
        square = count * count;
        printf("square of %d is %d",count,square);     
        sum =square + sum;
        printf(" running total is %d\n", sum);}

    printf("overall total of squares of integers 1 thru 10 is %d\n", sum);           

    return 0;
}
    


Output:
1
2
3
4
5
6
7
8
9
10
square of 1 is 1 running total is -1086072955
square of 2 is 4 running total is -1086072951
square of 3 is 9 running total is -1086072942
square of 4 is 16 running total is -1086072926
square of 5 is 25 running total is -1086072901
square of 6 is 36 running total is -1086072865
square of 7 is 49 running total is -1086072816
square of 8 is 64 running total is -1086072752
square of 9 is 81 running total is -1086072671
overall total of squares of integers 1 thru 10 is -1086072671


Create a new paste based on this one


Comments: