Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 21-08-17
- Fibonacci Series
- #include<stdio.h>
- int main()
- {
- int i,n,f1=0,f2=1,f3;
- printf("Enter the term of Fibonacci series ::");
- scanf("%d",&n);
- printf("Fibonacci series is %d \t%d",f1,f2);
- for(i=0;i<=n;i++)
- {
- f3=f1+f2;
- f1=f2;
- f2=f3;
- printf("\t%d",f3);
- }
- return 0;}
- Nested loop
- #include<stdio.h>
- int main()
- {
- int i,j,n;
- scanf("%d",&n);
- for(i=1;i<=n;i++)
- {
- for(j=1;j<=i;j++)
- {
- printf("*");
- }
- printf("\n");
- }
- return 0;
- }
- Nested1
- #include<stdio.h>
- int main()
- {
- int i,j,n;
- scanf("%d",&n);
- for(i=1;i<=n;i++)
- {
- for(j=5;j>=i;j--)
- {
- printf("*");
- }
- printf("\n");
- }
- return 0;
- }
- Nested2
- #include<stdio.h>
- int main()
- {
- int i,j,n;
- scanf("%d",&n);
- for(i=1;i<=n;i++)
- {
- for(j=1;j<=i;j++)
- {
- printf("*");
- }
- printf("\n");
- }
- for(i=1;i<=n;i++)
- {
- for(j=5;j>=i;j--)
- {
- printf("*");
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement