Hi All!
I am getting a problem in using scanf for yes/no condition
Code:
#include <stdio.h>
#include <conio.h>
#include <ctype.h>
long fibonacci(int count);
void main()
{
int count,n;
char resp='Y';
clrscr();
do
{
printf("\nHow many fibonacci: ");
scanf("%d",&n);
for(count=1;count<=n;++count)
printf("\ni= %2d\tF= %ld", count, fibonacci(count));
printf("\nDo you want to check again? (Y/N):");
scanf("%c",&resp);
}while(toupper(resp)!='N');
printf("\nBye, have a nice day!");
getch();
}
long fibonacci(int count)
{
static long int f1=1, f2=1;
long int f;
f=(count<3)?1:f1+f2;
f2=f1;
f1=f;
return(f);
}
Here i am facing the problem that this programme is not asking to user for the condition "Do You want to contineu Y/N: ".
Please help..
Anil