Advertisement
bilasi

Untitled

Apr 21st, 2014
464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. /*fibnacci*/
  2. #include<stdio.h>
  3. int fib(int n){
  4. int a[100], i;
  5. a[0] = 0;
  6. a[1] = 1;
  7. scanf("%d", &n);
  8. for(i = 2; i<n; i++){
  9. fib[i] = fib[i-1] + fib[i-2];
  10. }
  11. for(i = 0; i<n; i++){
  12. printf("%d ", fib[i]);
  13. }
  14. return n;
  15. }
  16. int main()
  17. {
  18. int a;
  19. fib(a);
  20.  
  21. return 0;
  22. }
  23.  
  24.  
  25. /*max between three Numbers
  26. #include<stdio.h>
  27. void max(int x, int y, int z){
  28. if(x>y && x>z)
  29. printf("max is ->%d\n", x);
  30. else if(y>x && y>z)
  31. printf("Max is -> %d\n", y);
  32. else
  33. printf("Max is: %d\n", z);
  34. }
  35. int main()
  36. {
  37. int a, b, c;
  38. scanf("%d %d %d", &a, &b, &c);
  39.  
  40. max(a, b, c);
  41.  
  42. return 0;
  43. }
  44.  
  45.  
  46. /*ODD - EVEN
  47. #include<stdio.h>
  48. int oe(int n){
  49. //int x;
  50. scanf("%d", &n);
  51. if(n%2 == 0)
  52. printf("Even\n");
  53. else
  54. printf("ODD\n");
  55.  
  56. return n;
  57. }
  58.  
  59. int main()
  60. {
  61. int a;
  62. oe(a);
  63.  
  64. return 0;
  65. }
  66.  
  67. /*factorial
  68. #include<stdio.h>
  69. void fac(int x){
  70. int f = 1, i, n;
  71. scanf("%d", &n);
  72. for(i = 1; i<=n; i++)
  73. f = f * i;
  74. printf("%d", f);
  75.  
  76. }
  77. int main()
  78. {
  79. int a;
  80. //scanf("%d", &a);
  81. fac(a);
  82. // printf("%d", fac(a));
  83. return 0;
  84. }
  85.  
  86.  
  87. /*add using function
  88. #include<stdio.h>
  89. int f(int x, int y){
  90. //printf("%d", x+y);
  91. return x+y;
  92. }
  93. int main()
  94. {
  95. int a, b;
  96. scanf("%d %d", &a, &b);
  97. f(a, b);
  98. printf("%d", f(a,b));
  99. return 0;
  100. }
  101. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement