6. Write a Program for Perfect Number?
Answer:
#include<iostream.h>
#include<conio.h>
Void main()
{
int num, perfect=0,i;
clrscr();
Cout<<"Enter any Number:";
cin>>num;
i=1;
while(i<num)
{
if(num%1==0)
perfect += i;
i++;
}
if(perfect == num)
Cout<<"endl<<"Perfect Number";
else
Cout<<"endl<<"Not Perfect Number";
getch();
}
...................................................................................................................................................................
7. Write a Program for Product of Two Number.
Answer:
#include<iostream.h>
#include<conio.h>
Void main()
{
int a,b,c;
Cout<<"Enter the First Number";
cin>>a;
Cout<<"Enter the Second Number";
cin>>b;
c = a*b;
Cout<<"The Product = "<<c;
getch();
}
Answer:
#include<iostream.h>
#include<conio.h>
Void main()
{
int num, perfect=0,i;
clrscr();
Cout<<"Enter any Number:";
cin>>num;
i=1;
while(i<num)
{
if(num%1==0)
perfect += i;
i++;
}
if(perfect == num)
Cout<<"endl<<"Perfect Number";
else
Cout<<"endl<<"Not Perfect Number";
getch();
}
...................................................................................................................................................................
7. Write a Program for Product of Two Number.
Answer:
#include<iostream.h>
#include<conio.h>
Void main()
{
int a,b,c;
Cout<<"Enter the First Number";
cin>>a;
Cout<<"Enter the Second Number";
cin>>b;
c = a*b;
Cout<<"The Product = "<<c;
getch();
}
...................................................................................................................................................................
8. Input Five Numbers and Find their Average.
Answer:
#include<iostream.h>
#include<conio.h>
Void main()
{
int a,b,c,d,e,sum,avg;
Cout<<"Enter The Five Number";
cin>>a>>b>>c>>d>>e;
sum = a+b+c+d+e;
avg = sum/5;
Cout<<" The Average = "<<avg;
getch();
}
...................................................................................................................................................................
9. Write a Program that input radius of circle and Find out the Area of Circle.
Answer:
#include<iostream.h>
#include<conio.h>
Void main()
{
float r, circle;
Cout<<"Enter the Radius of Circle";
cin>>r;
circle = 3.14*r*r;
Cout<<"Area of Circle = "<<circle;
getch();
}
...................................................................................................................................................................
10. Program to check the number that is Negative or Positive.
Answer:
#include<iostream.h>
#include<conio.h>
Void main()
{
int a;
Cout<<"\n Enter a Number";
cin>>a;
if(a<0)
{
Cout<<"\n Number is Negative";
}
else
{
Cout<<"\n Number is Positive";
}
getch();
}
*********************************************************************************
0 comments:
Post a Comment