#inlude%26lt;stdio.h%26gt;
main()
{int fib1, fib2, pairs, loop_index=3, month;
printf("Rabbit pairs produced in which month?....:");
scanf("%d", %26amp;month);
if (month ==1||month ==2)
pairs=1;
else
{
fib1=fib2=1;
while (loop_index++%26lt;=month)
{
pairs=fib1+fib2;
fib1=fib2;
fib2=pairs;
}
}
printf("The number of pairs produced in month %d is %d", month, pairs);
getch();
}
--------------------------------------...
this is showing error in the last printf function line.
can anyone hlp me to solve it out.
Whats wrong in this c programm ::-?
nothing wrong in the problem it works fine te only problem is the include statement at the top
#include%26lt;stdio.h%26gt;
(c in include is missing)
main()
{int fib1, fib2, pairs, loop_index=3, month;
printf("Rabbit pairs produced in which month?....:");
scanf("%d", %26amp;month);
if (month ==1||month ==2)
pairs=1;
else
{
fib1=fib2=1;
while (loop_index++%26lt;=month)
{
pairs=fib1+fib2;
fib1=fib2;
fib2=pairs;
}
}
printf("The number of pairs produced in month %d is %d", month, pairs);
getch();
}
Reply:i didt find any error on my pc, it was displayed the result correctly, check it again,
and when ever u use getch command, u have to use conio.h header file,
Type conio.h header file at starting and try, it will work
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment