/*Write a c program to find the sum of the s=1+2+3+4+5+.....+n series by indirect method using for loop */ #include <stdio.h> #include <stdlib.h> int main() { int n,i,sum=0; printf("Enter the value of n :\n"); scanf("%d",&n); for(i=1;i<=n;i++) sum=sum+i; printf("Sum = %d\n",sum); return 0; }
Enter the value of n : 10 Sum = 55
No comments:
Post a Comment