This is my homework question. I'm still pretty new to programming with C using Keil/uVision. I'm not looking for the direct answers and would like to learn but I have no idea what I am doing wrong or right really. I know a basic background of c++. This is what I have so far for the first part. Any help would be greatly appreciated.
Write a C-program to: •Automatically generate the Fibonacci sequence numbers up to 233 from an input given by the user on P1 (lower 4 bits). •Display each number up to the input index value on P2 (e.g. if P1 inputs 00000011, first three numbers of the series will be displayed on P2 with a delay in between) and allow a 250 ms delay for the user to observe the displayed value. Assume a delay sub-routine is available for your use.
------My Code Below------
#include <reg51.h>
void main() {
sbit T1 = P1; int fib = 0; int prev = 0; T1 = 1; for (int i = 0; i < T1; i++) { while (i == 1) { fib = 1; i++; } i--; fib = fib + prev; prev = fib; }
}
Sorry about that. That was just a copy error on my part from uvision.
NEVER copy always use cut-and-paste
I guess I’m more asking about the part where it has me taking the user input and putting it into p1 and using that for how many sequences it goes through.
I guess "putting it into p1" should be getting it from P1 x = P1;
how many sequences? just keep going till you have a value greater than the max specified