1. Write a program to find factorial of given number using for loop c program
2. Write a Program to check wether number is armstrong or not armstrong c program
3. Write a Program to check wether numberis palindron or not Palindron c program
1.
Write a program to find factorial of given number using for loop c program
/* Write a program to find factorial of given number using for loop */
#include<stdio.h>
#include<conio.h>
void main()
{
int num,i,fact=1;
clrscr();
printf("Enter Number : ");
scanf("%d",&num);
for(i=1;i<=num;i++)
{
fact = fact*i;
}
printf("Factorial = %d",fact);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int num,i,fact=1;
clrscr();
printf("Enter Number : ");
scanf("%d",&num);
for(i=1;i<=num;i++)
{
fact = fact*i;
}
printf("Factorial = %d",fact);
getch();
}
Download Program source code
2.
Write a Program to check wether number is armstrong or not armstrong c Program
/* Write a Program to check wether number is armstrong or not armstrong
Ex :- 153 = 1^3+5^3+3^3 = 153 */
#include<stdio.h>
#include<conio.h>
void main()
{
int i,num,temp,t,sum=0;
clrscr();
printf("Enter number : ");
scanf("%d",&num);
temp = num;
while(num>0)
{
t=num%10;
num = num/10;
sum = sum + t*t*t;
}
if(temp == sum)
{
printf("Number is Armstrong");
}
else
{
printf("Number is Not Armstrong");
}
getch();
}
/* Write a Program to check wether number is armstrong or not armstrong
Ex :- 153 = 1^3+5^3+3^3 = 153 */
#include<stdio.h>
#include<conio.h>
void main()
{
int i,num,temp,t,sum=0;
clrscr();
printf("Enter number : ");
scanf("%d",&num);
temp = num;
while(num>0)
{
t=num%10;
num = num/10;
sum = sum + t*t*t;
}
if(temp == sum)
{
printf("Number is Armstrong");
}
else
{
printf("Number is Not Armstrong");
}
getch();
}
Download Program source code
3.
Write a Program to check wether numberis palindron or not Palindron
/* Write a Program to check wether number is palindron or not Palindron
Ex :- 1331 revers = 1331 */
#include<stdio.h>
#include<conio.h>
void main()
{
int i,num,temp,t,sum=0;
clrscr();
printf("Enter number : ");
scanf("%d",&num);
temp = num;
while(num>0)
{
t=num%10;
num = num/10;
sum = sum*10 + t;
}
if(temp == sum)
{
printf("Number is Palindron");
}
else
{
printf("Number is Not Palindron");
}
getch();
}
#include<conio.h>
void main()
{
int i,num,temp,t,sum=0;
clrscr();
printf("Enter number : ");
scanf("%d",&num);
temp = num;
while(num>0)
{
t=num%10;
num = num/10;
sum = sum*10 + t;
}
if(temp == sum)
{
printf("Number is Palindron");
}
else
{
printf("Number is Not Palindron");
}
getch();
}
Download Program source code
0 Comments
If You have any query, Please let me know..