Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*fibnacci*/
- #include<stdio.h>
- int fib(int n){
- int a[100], i;
- a[0] = 0;
- a[1] = 1;
- scanf("%d", &n);
- for(i = 2; i<n; i++){
- fib[i] = fib[i-1] + fib[i-2];
- }
- for(i = 0; i<n; i++){
- printf("%d ", fib[i]);
- }
- return n;
- }
- int main()
- {
- int a;
- fib(a);
- return 0;
- }
- /*max between three Numbers
- #include<stdio.h>
- void max(int x, int y, int z){
- if(x>y && x>z)
- printf("max is ->%d\n", x);
- else if(y>x && y>z)
- printf("Max is -> %d\n", y);
- else
- printf("Max is: %d\n", z);
- }
- int main()
- {
- int a, b, c;
- scanf("%d %d %d", &a, &b, &c);
- max(a, b, c);
- return 0;
- }
- /*ODD - EVEN
- #include<stdio.h>
- int oe(int n){
- //int x;
- scanf("%d", &n);
- if(n%2 == 0)
- printf("Even\n");
- else
- printf("ODD\n");
- return n;
- }
- int main()
- {
- int a;
- oe(a);
- return 0;
- }
- /*factorial
- #include<stdio.h>
- void fac(int x){
- int f = 1, i, n;
- scanf("%d", &n);
- for(i = 1; i<=n; i++)
- f = f * i;
- printf("%d", f);
- }
- int main()
- {
- int a;
- //scanf("%d", &a);
- fac(a);
- // printf("%d", fac(a));
- return 0;
- }
- /*add using function
- #include<stdio.h>
- int f(int x, int y){
- //printf("%d", x+y);
- return x+y;
- }
- int main()
- {
- int a, b;
- scanf("%d %d", &a, &b);
- f(a, b);
- printf("%d", f(a,b));
- return 0;
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement