Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

1 /*Name:pascal Lindsay

2 Date11/1/17
3 desc:A program to print the square of all the integers from 1 to N and calculate their sum*/
4
5
6 #include <stdio.h>
7 #include <conio.h>
8
9 int main()
10 {
11 int n,square,x,squaresum;
12 squaresum=0;
13 printf("Please enter an integer value \n");
14 scanf("\n %d",&n);
15 for(x=1;x<=n;x++)
16 {
17 square=(x*x);
18 printf("\n The number is %d",x);
19 printf("\n With a square of %d",square);
20 squaresum=square+squaresum;
21 }
22 if(squaresum<=1000)
23 {
24 printf("\n The sum is %d",squaresum);
25 }
26 else
27 {
28 printf("\n THE SUM IS GREATER THAN ONE THOUSAND!");
29 }
30 getch();
31
32 return 0;
33 }

You might also like