Friday, March 20, 2015

Re-Enter on c programe



#include 
int fib (int i) 
{
  int pred, result, temp;
  
  pred = 1;
  result = 0;
 
  while (i > 0) 
{
    temp = pred + result;
    result = pred;
    pred = temp;
    i = i-1;
  }
  return(result);
}
 
int main () 
{
  int n;
  cout << "Enter a natural number: ";
  cin >> n;
  while (n < 0)
 {
    cout << "Please re-enter: ";
    cin >> n;
  }
  cout << "fib(" << n << ") = " << fib(n) << endl;
  return(0);
}
 
 

1 comment:

  1. Hotel near Harrah's, Atlantic City, NJ - Mapyro
    View 김제 출장마사지 reviews, information, directions, and reviews of Harrah's Atlantic City, NJ - 군포 출장마사지 Harrah's Hotel 보령 출장샵 and Casino, Atlantic City, 진주 출장마사지 United States - 안동 출장마사지 Mapyro.

    ReplyDelete