Basic C language Programme. like Fibonacci series, factorial of a number
§ 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();
}