Search
 
SCRIPT & CODE EXAMPLE
 

C

c programming programiz

#include <stdio.h>
int main() {

  int i, n;

  // initialize first and second terms
  int t1 = 0, t2 = 1;

  // initialize the next term (3rd term)
  int nextTerm = t1 + t2;

  // get no. of terms from user
  printf("Enter the number of terms: ");
  scanf("%d", &n);

  // print the first two terms t1 and t2
  printf("Fibonacci Series: %d, %d, ", t1, t2);

  // print 3rd to nth terms
  for (i = 3; i <= n; ++i) {
    printf("%d, ", nextTerm);
    t1 = t2;
    t2 = nextTerm;
    nextTerm = t1 + t2;
  }

  return 0;
}
Comment

PREVIOUS NEXT
Code Example
C :: C Syntax of realloc() 
C :: increment pointer value in c 
C :: how to read and write to fiel n c 
C :: how to input a string into a char array cpp 
C :: bitwise operators 
C :: create syscall 
C :: hostbuilder add environment variables 
C :: C/AL Convertion of Decimal to String/Text 
C :: voide means in c 
C :: cast from float to long c 
C :: what happens if i acess a freed variable in c 
C :: left me on read 
C :: User input in struct 
C :: divide a linked list into three parts based on their position mod 3. 
C :: npm fs zip 
C :: libreoffice reference cell in different sheet with sheet name with space 
C :: overhead computer science 
C :: c program to take array input from user 
C :: Clearing The Input Buffer In C/C++ 
C :: how to initiate pointer array with null in c 
C :: getopt optstr 
C :: what to do after autoencoder training 
C :: os.listdir to array 
C :: how to compress image in c 
C :: terrenery opertori with return in c 
C :: Write a c program to add two numbers without using addition operator. 
C :: tableau c 
C :: default password raspberry pi 
Dart :: change color of drawer icon flutter 
Dart :: listtile remove padding flutter 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =