5 Computer -- Programming II

Write a C program to generate Fibonacci series. [0,1,1,2, 3, 5, 8...10th term]

Write a C program to generate Fibonacci series. [0,1,1,2, 3, 5, 8...10th term]

#include<stdio.h>

int main()

{

    int a=0;

    int b=1;

    printf("%d %d ",a,b);

    for(int i=0;i<10;i++)

    {

        int c=a+b;

        a=b;

        b=c;

        printf("%d ",c);

    }

}




Output: 

0 1 1 2 3 5 8 13 21 34 55 89 

More questions on Programming II

Differentiate between structure and union.

Structures in Cis a user-defined data type available in C that allows to combining of data items of different kinds. Structures are used to represent a record.

Defining a structure:To define astructure, you must use thestructstatement. The struct statement defines a newdata type, with more than or equal to one member. The format of the struct statement is as follows:

struct [structure name] { member definition; member definition; ... member definition; }; (OR) struct [structure name] { member...
Close Open App