Menus

Tuesday 31 March 2020

To check given number is armstrong number or not



#include<stdio.h>

void main()
{

int n,m,b=0,a;

printf("Enter the number ");
scanf("%d",&n);

m=n;

while(n>0)
{

a=n%10;
n=n/10;
b=b+(a*a*a);

}

if(m==b)
  printf("%d is amstrong\n",m);
else
  printf("%d is not amstrong\n",m);


}






Friday 27 March 2020

Write C program to find factorial of a number


#include<stdio.h>

void main()
{


int n,fact;

printf("Enter the number ");
scanf("%d",&n);

fact=1;

while(n!=0)
{
fact = fact * n;
n--;
}

printf("Factorial of the nmber is %d\n",fact);


}