Write a C program to check whether a input number is perfect number of not.
#include<conio.h>
#include<stdio.h>
void main()
{
int no,i,sum;//no=number, sum=sum of divisor
//accept number
printf("\nEnter any number: ");
scanf("%d",&no);
sum=0;
//check divisors of n
for(i=1;i<no/2;i++)
{
if(i%2==0)
{
sum=sum+no;
}
}
//to check original number and sum of divisor till given number
if(sum==no)
{
printf("\n%d is Perfect Number.",sum);
}
else
{
printf("\n%d is not Perfect Number.",no);
}
getch();
}
-
Next Write a program having a menu with the following options and corresponding actions. Options Actions 1. Area of square Accept length ,Compute area of square and print 2. Area of Rectangle Accept length and breadth, Compute area of rectangle and print 3. Area of triangle Accept base and height , Compute area of triangle and print
0 Comments