|Sum of series in c|
C PROGRAM TO FIND SUM OF SERIES
Code:
#include<stdio.h>
int main()
{
int i,N;
unsigned long sum;
printf("Enter the value of N: ");
scanf("%d",&N);
sum=0;
for(i=1;i<=N;i++)
sum= sum+
(i*i);
printf("Sum of the
series is: %ld\n",sum);
return
0;
}
Explanation:
-
To find sum of series we get the required data from the user by
using the statement
"printf".
-
The next step is we are storing the user given data in some
variable called "N".
-
Then we are processing it using the above statements.
-
Then to get the desired output we are printing the exact
statement to be displayed again using printf statement.
output:
- To find sum of series we get the required data from the user by using the statement "printf".
- The next step is we are storing the user given data in some variable called "N".
- Then we are processing it using the above statements.
- Then to get the desired output we are printing the exact statement to be displayed again using printf statement.
Comments
Post a Comment