Advertisement Remove all ads

Wap to Print the Sum of Following Series.1+22+33+………+Nn - Structured Programming Approach

Short Note

WAP to print the sum of following series.

1+22+33+………+nn

Advertisement Remove all ads

Solution

#include<stdio.h>
#include<conio.h>
void main()
{
int n,sum=0;
clrscr();
printf("Enter a number ");
scanf("%d",&n);
while(n!=0)
{
sum=sum+(n*n);
n--;
}
printf("The sum of the series is %d",sum);
getch ();
}

Output:
Enter a number 3
The sum of the series is 14

  Is there an error in this question or solution?
Advertisement Remove all ads

APPEARS IN

Advertisement Remove all ads
Advertisement Remove all ads
Share
Notifications

View all notifications


      Forgot password?
View in app×