#include<stdio.h>
///1 + 2 + 3 + … + n
int main(){
int n,i;
int sum=0;
printf("Enter any end number of this series: ");
scanf("%d",&n);
sum = (n * (n + 1)) / 2;
printf("Sum of the series: ");
for(i =1;i <= n;i++){
if (i!=n)
printf("%d + ",i);
else
printf("%d=%d ",i,sum);
}
return 0;
}
No comments:
Post a Comment