Hi, can any one help me with this?
i use Quincy 2005
i've made a fibonacci program in C :--->
Code:
#include <malloc.h>
#include <stdlib.h> 

int main()

{     

int NUM_FIBON;
int *farray;
int i;
    
printf("Enter a number \t");
scanf("%d",&NUM_FIBON);

    /* Display the purpose of the program */
    printf("\nThis program displays the first %d fibonacci numbers\n",NUM_FIBON);
    
farray = (int *) malloc(NUM_FIBON);

farray[0] = 1;
farray[1] = 1;


for (i = 2; i < NUM_FIBON; i++ )
    {
    farray[i] =farray[i -1] + farray[i - 2];
    
    }
      
     for (i = 0; i < NUM_FIBON; i++ )
     {
     printf(" %-8i ",farray[i]);
     }

}
<----------------

now i have been asked to change the code so that the program
asks repeatedly for a new number of Fibonacci numbers until the user decides to quit. The user's decision to continue or not is taken within a simple user-defined function.
Design this, say, "continueOK" function to take no parameter, but return a boolean value
(bool type). The function should return true when the user types 'Y' or 'y', false when the user enters 'N' or 'n'.
You need to #include <stdbool.h>.
The stdbool.h header defines the type bool, and values true and false.
Within the "continueOK" function, you have to do a case-insensitive check of
whether the character entered by the user is 'Y' or 'N'. You can use the
toupper system function to convert the character to uppercase. For this you
need to #include <ctype.h>.
Use Strict ANSI/ISO Compliance and C99 support for C programs.

I tried using a do - while loop but could not achieve anything..
you wil need to #include <stdbool.h> , #include <ctype.h> , #include <stdio.h>

Last edited by shabbir; 31Mar2009 at 07:36.. Reason: Code blocks