#include
#include
void main()
{
clrscr();
int i=1, u=1, sum=0;
while(i<=500)
{
while(u<=500)
{
if(u
{
if(i%u==0 )
sum=sum+u;
}
u++;
}
if(sum==i)
{
cout<
}
i++;
u=1; sum=0;
}
getch();
}
C++
Program To Find Prime Numbers
#include
#include
void
main()
{
clrscr();
int
number,count=0;
cout<<"Enter number to check
it is prime or not ";
cin>>number;
for(int
a=1;a<=number;a++)
{
if(number%a==0)
{
count++;
}
}
if(count==2)
{
cout<<" Prime number \n";
}
else
{
cout<<" Not a prime number \n";
}
getch();
}
hours minutes and seconds in both
12 and 24 hours format:
#include
#include
void main()
{
clrscr();
int
hours,mins,seconds,x;
cout<<"Enter hours=";
cin>>hours;
cout<<"\nEnter
minutes=";
cin>>mins;
cout<<"\nEnter
seconds=";
cin>>seconds;
if(hours
> 24)
{
cout<<"Invalid
Entery";
}
else
{
cout<<"\n24
Hours Format\n";
cout<<"Hours :
Mins : Seconds\n"<<" "<
"<
if(hours > 12)
{
hours=hours-12;
cout<<"12
Hours Format\n";
cout<<"Hours :
Mins : Seconds\n"<<" "<
"<
}
Else
{
cout<<"12
Hours Format\n";
cout<<"Hours
: Mins : Seconds\n"<<"
"< "<
}
}
}
No comments:
Post a Comment