#include<stdio.h>
#include<conio.h>
void main()
{
int n, d, a, sum = 0;
clrscr();
printf("Enter the number : ");
scanf("%d", &n);
a = n;
while (a > 0)
{
d = a % 10;
sum = sum + d;
a = a / 10;
}
if (n % sum == 0)
printf("\nThe number is Niven Number.");
else
printf("\nThe number is not a Niven Number.");
getch();
}
72. Program to check whether the number is palindrome or not.
#include<stdio.h>
#include<conio.h>
void main()
{
int n, rev = 0, temp;
clrscr();
printf("Enter a number : ");
scanf("%d", &n);
temp = n;
while (temp != 0)
{
rev = rev * 10;
rev = rev + temp % 10;
temp = temp / 10;
}
if (n == rev)
printf("\n%d is palindrome number.", n);
else
printf("\n%d is not palindrome number.", n);
getch();
}
73. Program to check perfect number.
#include<stdio.h>
#include<conio.h>
void main()
{
int n, i = 1, sum = 0;
clrscr();
printf("Enter a number : ");
scanf("%d", &n);
/The first perfect number is 6, because 1, 2, and 3 are its proper positive divisors, and 1 + 2 + 3 = 6./
while (i < n)
{
if (n % i == 0)
{
sum = sum + i;
}
i++;
}
if (sum == n)
{
printf("\n%d is a perfect number.", i);
}
else
{
printf("\n%d is not a perfect number.", i);
}
getch();
}
74. Program to find the square root of a number.
#include<math.h>
#include<stdio.h>
#include<conio.h>
void main()
{
double num, result;
clrscr();
printf("Enter number : ");
scanf("%lf", &num);
result = sqrt(num);
printf("Square root of %lf is %lf.", num, result);
getch();
}
75. Program to print sum of 'n' prime numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int n, i = 3, count, c, sum = 2;
clrscr();
printf("Enter total number of prime numbers for addition : ");
scanf("%d", &n);
if (n >= 1)
{
printf("\nFirst %d prime numbers are :", n);
printf("\n2 ");
}
for (count = 2; count <= n;)
{
for (c = 2; c <= i - 1; c++)
{
if (i % c == 0)
break;
}
if (c == i)
{
sum = sum + i;
printf("%d ", i);
count++;
}
i++;
}
printf("\nSum : %d", sum);
getch();
}