#include <iostream>
//Function Prototypes
void qFive();
void Questions();
void qSix();
int main()
{
using namespace std;
Questions();
cout << "Press any key to exit;" << endl;
cin.get();
return 0;
}
void Questions()
{
using namespace std;
cout << "Type the question number to proceed. Press 0 To Exit" << endl;
int qNum;
if(cin >> qNum)
{
switch(qNum)
{
case 5:
qFive();
break;
case 0:
break;
case 6:
qSix();
break;
default:
break;
}
}
//reset the error flag
cin.clear();
while(cin.get() != '\n')
{
continue;
}
}
void qFive()
{
using namespace std;
//Calculate the Factorial value of the given number
cout << "Write down a number to calculate its factorial value" << endl;
int num,temp;//5 = 5*4*3*2*1
cin >> num;
cout << "Typed Value " << num << endl;
temp = num;
while(1)
{
num--;
if(num==0)break;
temp = temp * (num);
}
cout << "Its Factorial value " << temp << endl;
//Reask the Questions ,Looping
Questions();
}
void qSix()
{
//receive 10 numbers and the display maximum number out of it
using namespace std;
cout << "Write 10 Numbers to get its Maximum value" << endl;
double* num = new double[10];//3 9 1 5
for(int i=0;i<10;i++)
{
cin >> num[i];
}
int maxValue;
maxValue = num[0];
for(int i=0;i<10;i++)
{
if(maxValue == num[i])
{}
else if(maxValue < num[i])
{
maxValue = num[i];
}
else if(maxValue > num[i])
{}
}
cout << "The Maximum number out of 10 is " << maxValue << endl;
delete[] num;
}