compute the nth mumber in the fibonacci sequence?
Answer Posted / selloorhari
// n th number of a fibonacci series
#include<stdio.h>
#include<conio.h>
void main ()
{
int i,k = 0 , j = 1 ,n,res;
printf ( " \n enter the number " );
scanf ( "%d",&n ) ;
// printf ( "\n the series is 0, 1" ) ;
for ( i= 2 ; i<n;i++ )
{
res= k+j ;
k=j;
j=res;
// printf ( ", %d" ,res ) ;
}
printf ( " \n The n th term is %d " ,res ) ;
getch() ;
}
| Is This Answer Correct ? | 10 Yes | 1 No |
Post New Answer View All Answers
find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2
What is scope and lifetime of a variable in c?
What are the advantages of external class?
Write the test cases for checking a variable having value in range -10.0 to +10.0?
What is structure padding and packing in c?
What are the features of c languages?
Can main () be called recursively?
Why do we use header files in c?
What is chain pointer in c?
Write a C program that will accept a hexadecimal number as input and then display a menu that will permit any of the following operations to be carried out: Display the hexadecimal equivalent of the one's complement. (b) Carry out a masking operation and then display the hexadecimal equivalent of the result. (c) Carry out a bit shifting operation and then display the hexadecimal equivalent of the result. (d) Exit. If the masking operation is selected, prompt the user lor the type of operation (bitwise and, bitwise exclusive or, or bitwise or) and then a (hexadecimal) value for the mask. If the bit shifting operation is selected. prompt the user for the type of shift (left or right), and then the number of bits. Test the program with several different (hexadecimal) input values of your own choice.
How many identifiers are there in c?
Describe the difference between = and == symbols in c programming?
write a program in c language to print your bio-data on the screen by using functions.
Does c have class?
How do you print only part of a string?