write a program which consists of a user defined function compute (),it should take one integer argument .this function should return the count of odd fibonacci terms from starting to integer argument value passed into function
Answers
Answered by
0
Program is given below.
Explanation:
#include <stdio.h>
void compute(int);
int main()
{
int n;
printf("Enter a integer: \n");
scanf("%d",&n);
compute(n);
}
void compute(int number)
{
int i,count=0;
int a=0,b=1,c;
printf("Odd Fibonacci Series terms are:\n");
for (i=0;i<number;i++)
{
if(a%2!=0)
{
printf("%d ",a);
count=count+1;
}
c=a+b;
a=b;
b=c;
}
printf("\nThe count of odd fibonacci terms is equal to %d.",count);
}
Refer the attached image for the output.
Attachments:
Answered by
0
Answer:
Write a C function isodd(num) that accepts an integer argument and returns 1 if the argument is odd and 0 otherwise.
Similar questions