Archive for the ‘Lab 8’ Category

#include <stdio.h>
int main()
{
   int number, sum = 0, n, remainder;
   printf("Enter a number\n");      
   scanf("%d",&number);
   n = number;
 
   while( n != 0 )
   {
      remainder = n%10;
      sum = sum + remainder*remainder*remainder;
      n = n/10; 
   }
 
   if ( number == sum )
      printf("Entered number is an armstrong number.");
   else
      printf("Entered number is not an armstrong number.");         
 
   return 0;
}
Advertisements
#include<stdio.h>
int main()
{
int i,fact=1,n;
printf("Enter the no of terms =");
scanf("%d",&n);
for(i=1;i<=n;i++)
fact=fact*i;
printf("\nFactorial is = %d",fact);
return 0;
}

#include <stdio.h>
int main()
{
   int n, reverse = 0,num;
   printf("Enter a number to reverse\n");
   scanf("%d",&n);
	num=n;
   while (n != 0)
   {
      reverse = reverse * 10;
      reverse = reverse + n%10;
      n = n/10;
   }
   printf("Reverse of entered number is = %d\n", reverse);
if(reverse== num)
		{

    printf("\n The Number is Palindrome \n");
	}
    else{
    printf("\n The Number is not a Palindrome\n ");
}
   return 0;
}
#include<stdio.h>
int main()
{
int n,i,c=0;
printf("Enter a nnumber:");
scanf("%d",&n);
for(i=1;i<n;i++)
{
if(n%i==0)
{
c=c+i;
}
}
if(n==c)
printf("\nPerfect no.");
else
printf("\nNot a perfect no.");
return 0;
}
#include<stdio.h>
int main()
{
	int n;
	printf ("Enter a number: ");
scanf ("%d",&n);
	if(n%2==0)
	{
		printf("EVEN NUMBER");
	}
		else
	{
			printf("ODD NUMBER");
		}
	return 0;
}
#include<stdio.h>
int main()
{
int n;
printf ("Enter a number: ");
scanf ("%d",&n);
(n%2==0 ? printf("Even NUMBER"):printf ("ODD NUMBER"));
	return 0;
}

#include<stdio.h>
int main()
{
	int a,b,sum=0;
	printf("Enter Two numbers:\n");
	scanf("%d\t%d",&a,&b);
	sum=a+b;
	printf("\nSum is=%d",sum);
	return 0;
}