Advertisement
Istanvir389

21-08-17

Aug 21st, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. 21-08-17
  2.  
  3.  
  4. Fibonacci Series
  5. #include<stdio.h>
  6. int main()
  7. {
  8. int i,n,f1=0,f2=1,f3;
  9. printf("Enter the term of Fibonacci series ::");
  10. scanf("%d",&n);
  11. printf("Fibonacci series is %d \t%d",f1,f2);
  12. for(i=0;i<=n;i++)
  13. {
  14. f3=f1+f2;
  15. f1=f2;
  16. f2=f3;
  17. printf("\t%d",f3);
  18. }
  19. return 0;}
  20.  
  21. Nested loop
  22.  
  23. #include<stdio.h>
  24. int main()
  25. {
  26. int i,j,n;
  27. scanf("%d",&n);
  28. for(i=1;i<=n;i++)
  29. {
  30. for(j=1;j<=i;j++)
  31. {
  32. printf("*");
  33. }
  34. printf("\n");
  35. }
  36. return 0;
  37.  
  38. }
  39.  
  40.  
  41.  
  42. Nested1
  43. #include<stdio.h>
  44. int main()
  45. {
  46. int i,j,n;
  47. scanf("%d",&n);
  48. for(i=1;i<=n;i++)
  49. {
  50. for(j=5;j>=i;j--)
  51. {
  52. printf("*");
  53. }
  54. printf("\n");
  55. }
  56. return 0;
  57.  
  58. }
  59.  
  60.  
  61. Nested2
  62.  
  63. #include<stdio.h>
  64. int main()
  65. {
  66. int i,j,n;
  67. scanf("%d",&n);
  68. for(i=1;i<=n;i++)
  69. {
  70. for(j=1;j<=i;j++)
  71. {
  72. printf("*");
  73. }
  74. printf("\n");
  75. }
  76. for(i=1;i<=n;i++)
  77. {
  78. for(j=5;j>=i;j--)
  79. {
  80. printf("*");
  81. }
  82. printf("\n");
  83. }
  84. return 0;
  85.  
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement