Write a VSC (macro) program that computes and displays a Fibonacci sequence. A Fbonacci sequence is generated by adding the two most recent sequence numbers together, i.e., 1, 1, 1+1-2, 1+2=3, 2+3=5, 3+5=8, … The user will enter the number of terms in the sequence to be displayed. Assemble this program using the VSC assembler (ASM), and simulate this program using the VSC simulator (SIM). Include a copy of the source listing (SOURCE.DAT), the assembled listing (SLIST.DAT) and the simulation output.
Step1: open file -- new project
Step 2: install c/c++ extension, c/c++ command adaptor
Step 3: write the code of Fibonacci series
#include<studio.h>
int main()
{
int count, first_no= 0, second_no= 1,
next_no, i;
printf("Enter the number of terms in a series");
scanf("%d", &count);
printf("first_no");
for(i=0; i<count; i++)
{
if(i<=1)
next_no=I;
else
{ next_no=first_no+second_no;
first_no = second_no;
second_no=next_no;
}
printf("%d\n", next_no);
}
return 0;
}
Step 4: run the code on new terminal.
Get Answers For Free
Most questions answered within 1 hours.