/*wap using recursive function to generatr n terms and print the sum of following series for N terms.. 1+4+9+16+25+36+......+n=sum*/ #include<stdio.h> #include<conio.h> #include<math.h> int addition(int n); void main() { int n,sum; clrscr(); printf("enter value of n:"); scanf("%d",&n); sum=addition(n); printf("%d",sum); getch(); } int addition(int n) { int sum; if(n==1) { return(1); } else { return(pow(n,2)+addition(n-1)); } }
wap using recursive function to generatr n terms and print the sum of following series for N terms.. 1+4+9+16+25+36+......+n=sum
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment