Hey all, Programming newbie here.
I'm programming the Fibbonacci code, but I can't figure out how to set the condition
"if NOT EQUAL to any numerical value"
This is what I have so far:
Code:
#include <stdio.h>
#include <conio.h>
long fib(int);
int main()
{
int n;
printf("Enter the Fibbonacci number you would like to view: ");
scanf("%i", &n);
if (WHAT GOES HERE?)
{
printf("Input error.\n");
getch();
}
else if (n<0) {
printf("Fibonacci is undefined for negative integers.\n");
getch();
}
else {
printf("The %i-th Fibonacci number is %ld\n", n, fib(n));
}
getch();
return 0;
}
long fib(int n)
{
if (n == 1 || n == 2)
{
return 1;
}
else
{
return (fib(n-1) + fib(n-2));
}
}
Thanks for the help in advance!
Steel.