C Language

May 30, 2023

How to use generate in c language

program to use generate in c language


#include<stdio.h>
int main()
{
    long x,y,z;
    int i,n;
    x=0;
    y=1;
    printf("Enter the number of terms : ");
    scanf("%d",&n);
    printf("%1d ",y);
    for(i=1; i<n; i++)
    {
        z=x+y;
        printf("%1d ",z); 
        x=y;
        y=z;
    }
    printf("\n");
    return 0;
}

output


Enter the number of terms : 4
1 1 2 3

by : Ajaj Khan

Quick Summary:

program to use generate in c language copy #include&ltstdio.h> int main() { long x,y,z; int i,n; x=0; y=1; printf(“Enter the number of terms : “); scanf(“%d”,&n); printf(“%1d “,y); for(i=1; i<n; i++) { z=x+y; printf(“%1d “,z); x=y; y=z; } printf(“\n”); return 0; } output Enter the number of terms : 4 1 1 2 3