Arjun Suresh (talk | contribs) |
|||
Line 3: | Line 3: | ||
<syntaxhighlight lang="c"> | <syntaxhighlight lang="c"> | ||
#include<stdio.h> | #include<stdio.h> | ||
− | int | + | int fib(int n){ |
− | { | + | if(n<=2)return 1; |
− | + | else return fib(n-1)+fib(n-2); | |
− | + | } | |
− | + | main(){ | |
− | + | int n; | |
− | + | printf("enter the number "); | |
+ | scanf("%d",&n); | ||
+ | printf("fib(%d)=%d",n,fib(n)); | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> |
<quiz display="simple"> { What is the output of the following program? <syntaxhighlight lang="c">
int fib(int n){ if(n<=2)return 1; else return fib(n-1)+fib(n-2); } main(){ int n; printf("enter the number "); scanf("%d",&n); printf("fib(%d)=%d",n,fib(n)); } </syntaxhighlight> |type="{}" /} { Abc }
</quiz>
<quiz display="simple"> { What is the output of the following program? <syntaxhighlight lang="c">
int main() {
char str[] = {'a','b','c','\0'}; str[0] -= 32; printf("%s",str);
return 0;
} </syntaxhighlight> |type="{}" /} { Abc }
</quiz>