#include<iostream.h>
main()
{
int opt,x,y,fact,ans;
for(ans=opt;ans!=0;ans++)
{
cout<<"\n\t\t\t *******MENU*******"
<<"\n\t\t\t[1] FACTORIAL OF A NUMBER"
<<"\n\t\t\t[2] PRIME NUMBER"
<<"\n\t\t\t[3] ODD OR EVEN NUMBERS"
<<"\n\t\t\t[4] MULTIPLICATION TABLE"
<<"\n\t\t\tYOUR CHOICE: ";
cin>>opt;
switch(opt)
{
case 1:
{
cout<<"\nThis program tells you the Factorial of the number you have input...";
cout<<"\nInput limit: ";
cin>>y;
fact=1;
for(x=1;x<=y;x++)
{
fact=fact*x;
}
cout<<"\nThe factorial of the number you entered is "<<fact<<"."<<endl;
break;
}
case 2:
{
cout<<"INPUT: ";
cin>>x;
for(y=2;y<=x/2;y++)
{
if(x%y==0)
{
cout<<"Not Prime.";
}
}
cout<<"Prime number.";
break;
}
case 3:
{
cout<<"\nThis program will test if the number entered is an Odd or Even number...";
cout<<"Input a number: ";
cin>>x;
if(x%2==0)
cout<<"The number you entered is Even number.";
else
cout<<"Prime numberThe number you entered is Odd number.";
break;
}
case 4:
{
for(x=1;x<=5;x++)
{
cout<<"\n";
for(y=1;y<=5;y++)
cout<<"\t"<<x*y;
}
cout<<endl;
break;
}
default:
cout<<"INVALID CHOICE!!!"<<endl;
}
cout<<"\n\t\t\tDo you wish to repeat?\n Press any number to Repeat the program Or press -1 to end..: ";
cin>>ans;
}
cout<<endl;
return 0;
}
uNpReDiCtAbLe 0 Newbie Poster
sfuo 111 Practically a Master Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
mrnutty 761 Senior Poster
sfuo 111 Practically a Master Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.