Professional Documents
Culture Documents
Here I have written the Code, attached Link and also Screenshot.
1.Factorial :
#include <stdio.h>
int main()
{
int N,K,S;
scanf("%d",&N);
S=1;
for(K=1;K<=N;K=K+1)
{
S=S*K;
}
printf("Result: %d",S);
}
Link : https://onlinegdb.com/rJrpwYrWO
LCM=(L*S)/GCD;
printf("GCD = %d\n",GCD);
printf("LCM = %d\n",LCM);
return 0;
}
LINK : https://onlinegdb.com/BJlpuFH-d
Screenshot is given below,
3. find Reverse form of any integer number and sum of digit :
#include <stdio.h>
int main()
{
int n, rev=0 ,remainder,sum=0;
printf("Enter an integer: ");
scanf("%d", &n);
while (n != 0)
{
remainder = n % 10;
rev = rev * 10 + remainder;
n = n/10;
sum=sum+remainder;
}
printf("Reversed number = %d\n", rev );
printf("Sum of digit = %d", sum);
return 0;
}
LINK : https://onlinegdb.com/B1eL7dr8bO
Screenshot is given below,
4.Find Prime Number between two range :
#include <stdio.h>
int main()
{
// Declare the variables
int a, b, i, j, count;
if (i == 1 || i == 0)
continue;
return 0;
}
5.Fibonacci series upto Nth number :
#include<stdio.h>
int main()
{
int sum = 0,a=0,b=1, n;
printf("Enter the nth value: ");
scanf("%d", &n);
printf("Fibonacci series: ");
while(sum <= n)
{
printf("%d ", sum);
a = b; // swap elements
b = sum;
sum = a + b; // next term is the sum of the last two terms
}
return 0;
}
LINK: https://onlinegdb.com/BkDFnFSbO
Screenshot is given below,
THE END