If your Windows 11 taskbar is not showing, you can try several troubleshooting steps to resolve the issue. Here are some potential solutions you can try:
Here's how you can print the Fibonacci series in C language using a loop:
c#include <stdio.h>
int main() {
int n, t1 = 0, t2 = 1, nextTerm;
printf("Enter the number of terms: ");
scanf("%d", &n);
printf("Fibonacci Series: ");
for (int i = 1; i <= n; i++) {
printf("%d, ", t1);
nextTerm = t1 + t2;
t1 = t2;
t2 = nextTerm;
}
return 0;
}
In this code, we first take the input for the number of terms in the Fibonacci series to be printed. Then we initialize t1
and t2
as the first and second terms of the series respectively. We then use a for
loop to iterate from 1 to n
, printing each term of the series along the way.
Inside the loop, we print the current value of t1
, which is the current term of the series. We then calculate the value of the next term and update the values of t1
and t2
accordingly, so that we can continue printing the series.
The output will be a comma-separated list of the Fibonacci series up to the specified number of terms.
Comments
Post a Comment