Posts

Program in C++ to count heart beats of a person by its age from born

# include <iostream.h> int main() { int age,heartbeats; cout<<"Enter Age: "; cin>>age; cout<<"Enter Number of Heartbeats per min: "; cin>>heartbeats; heartbeats = heartbeats * 60; //heartbeats per hour heartbeats = heartbeats * 24; //heartbeats per day heartbeats = heartbeats * 365; //heartbeats per year cout<<"Your Heart has beat "<<heartbeats * age<<" times since you were born."<<endl; return 0; } -----------------------OUTPUT---------------------  Enter Age: 26  Enter Number of Heartbeats per min: 70  Your Heart has beat  956592000  times since you were born.

Program in C++ for Fibonacci Series using recursion function

#include<iostream.h> fibonacci(int);            //function prototype void main() { int n,i,f; cout<<"Enter the total elements in the series : "; cin>>n; cout<<"\nThe Fibonacci series is:\n"; for(i=0;i<n;i++)     {         f=fibonacci(i); //function call         cout<<f<<"  ";     } } fibonacci(int n)        //function definition {     int f;     if(n==0)     return 0;     else if(n==1)     return 1;     else     f=fibonacci(n-1)+fibonacci(n-2);  /*Two recursion function calling itself with different arguments.*/     return f; } -----------------OUTPUT--------------- Enter the total elements in the series :  7 The Fibon...