Course Content
Detailed Content of Programming in C
0/1
Introduction
0/1
Structure of C program
0/1
Answers of ‘C’ Pointers Programs
0/1
About Lesson

Print Fibonacci Series up to N terms using a For Loop.

#include <stdio.h>

int main() {
int N, a = 0, b = 1, nextTerm;

// Taking input for the number of terms
printf(“Enter the number of terms for Fibonacci series: “);
scanf(“%d”, &N);

// Printing Fibonacci series using a for loop
printf(“Fibonacci Series up to %d terms: “, N);
for (int i = 1; i <= N; i++) {
printf(“%d, “, a);
nextTerm = a + b;
a = b;
b = nextTerm;
}

return 0;
}