/*write a c program to add first 10 successive integer*/ #include<stdio.h> #include<conio.h> void main() { int x,n,i,ans=1; clrscr(); printf("enter value of x:"); scanf("%d",&x); printf("enter value of n:"); scanf("%d",&n); for(i=1;i<=n;i++) { ans=ans+x; } printf("ans:%d",ans); getch(); }
Showing posts with label Series. Show all posts
Showing posts with label Series. Show all posts
write a c program to add first 10 successive integer
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
/*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)); } }
write a c program to n terms of the folllowing series 1,1,2,3,5,8,13.....
/*write a c program to n terms of the folllowing series 1,1,2,3,5,8,13.....*/ #include<stdio.h> #include<conio.h> void main() { int n,i,a=1,b=1,c=0; clrscr(); printf("enter value of n:"); scanf("%d",&n); printf("\nthe fibonacci series "); for(i=1;i<=n;i++) { a=b; b=c; c=a; c=a+b; printf("%d",c); if(i<n) printf(","); else printf(""); } getch(); }
Wap to print Series : 1 11 111 1111.....
/*write a c program to n terms of the folllowing series 1,11,111,1111,.....*/ #include<stdio.h> #include<conio.h> void main() { int n,i,j; clrscr(); printf("enter value of n:"); scanf("%d",&n); printf("\nthe series "); for(i=1;i<=n;i++) { for(j=1;j<=i;j++) { printf("1"); } if(i<n) printf(","); else printf(""); } getch(); }
Subscribe to:
Posts (Atom)