Sum of the first 30 squares in C
Posted by Samath
Last Updated: December 21, 2014

Write a C program to find the sum of the squares of the integers f rom 1 to 30. Print the sum of the squares.

Solution:

#include <stdio.h>
using namespace std;
int main(int argc, char *argv[])
{
	int i; 
	int result = 0; 

	for (i = 1; i <= 30; i++)
	{
		result = result + (i * i);
	}
	printf ("%d is the sum of the first 30 squares.\n" ,result);
	
	return 0;
}