Basic C language Programme. like Fibonacci series, factorial of a number

Dipanjan sahoo
2 min readJan 3, 2021

--

§ Write a programme to display the following series 1,2,3,4,5,6,_ _ _ _ _ _,n ?

Answer:-

#inclued<stdio.h>

#include<conio.h>

void main()

{

int i,n;

printf(“Enter the value of n:”);

scanf(“%d”,&n);

for(i=1;i<=n;i++)

{ printf(“\t %d”,i);

}

getch();

Output:-

Enter the value of n: 5

1 2 3 4 5

§ Write a programme to find the Factorial of a given number?/ Write a program to find factorial of a number in c ?

Answer:-

#include<stdio.h>

#include<conio.h>

void main()

{

int a,i,n=1;

printf(“enter any value”);

scanf(“%d”,&a);

for(i=1;i<=a;i++)

{

n=n*i;

}

printf(given number factorial is:%d”,n);

getch();

}

§ Write a programme to display the following series and also calculate their sum?

Answer:

#include<stdio.h>

#include<conio.h>

void main()

{

int i,n,sum,p;

sum=o

printf(“Enter The Value of n:);

scanf(“%d”,&n);

for(i=1;i<=n;i++);

{

p=i*i;

printf(“%d\t”,p);

sum=sum+p;

}

printf(“sum of series =%d”,sum);

getch();

}

Output:-

Enter The value of n: 7

1 4 9 16 25 36 49

Sum of Series =140

§ Write a program to display Fibonacci series using C language?

Answer:.

Fibonacci series Using For Loop.

#include<stdio.h>

#include<conio.h>

void main()

{

int a,b,c,n,i;

a=0;

b=0;

printf(“Enter a Term of Series:”);

scanf(“%d”,&n);

printf(“\n FIBONACCI SERIES IS — — -\n ”);

printf(“%d”,a);

printf(“%d\t\t”,b);

for(“i=2;i<n;i++”)

{

c=a+b;

printf(“%d\t”,c);

printf(“%d\t”,c);

a=b

b=c

}

getch();

}

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Dipanjan sahoo
Dipanjan sahoo

Written by Dipanjan sahoo

0 Followers

hey i am dipanjan sahoo, i am a professional digital marketer,

No responses yet

Write a response