Pages

Labels

C Program to display sum of square up to 10

This is a simple java code that shows the sum of square of all digit from 1 to 10. You can run this program and check the output on any C platform.

Example:

#include<stdio.h>
#include<conio.h>
main() {
    int i, sq = 0;
    for(i=1 ;i <= 10; i++){
        sq+=i*i;
    }
    printf("sum of square = %d\n",sq);
}

Output:
sum of square = 385

How it works
It runs in following sequence to give the output:
1^2 + 2^2 + .... + 9^2 + 10^2 = 385

Followers