Hello, so i did the following code. What I want to do next is to make it unfixed so that I would be able to enter the area I want to start and area I want it to end.
For Example:
Enter the area you want to start : 1
are it will end: 5
So, it will show the multiplication table for 1,2,3,4,5 only up to x10.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>
usingnamespace std;
int main ()
{
cout << "\t1\t2\t3\t4\t5\t6\t7\t8\t9\t10" << endl;
for (int x=1; x<=10; x++)
{
cout << x << "|";
for (int y=1; y<=10; y++)
{
cout << x*y << "\t";
}
}
system ("pause");
return 0;
}
Also, I couldn't get "\t1\t2\t3\t4\t5\t6\t7\t8\t9\t10" to fit in the command prompt. Any workarounds?
EDIT:
I got another question.
What I want to do now is the program must return to the main menu unless the exit button is selected.
int x;
int sum=0;
int ave=0;
cout << " Program Menu " << "\n"
<< "Please choose one of the following programs" << "\n"
<< "Option 1: Input a number other than 999." << "\n"
<< "Option 2: Print //d// five times." << "\n"
<< "Option 3: Print a multiplication table." << "\n"
<< "Option 4: PassOrFail grade assessment." << "\n"
<< "Option 5: Count up to what the user enters" << "\n"
<< "Option 6: Exit" << endl;
cin >> x;
switch (x)
{
case 1:
int num;
cout << "Please input a number other than 999" << endl;
cin >> num;
while (num<999)
{
ave=ave+1;
sum=num+sum;
cin >> num;
}
if (num==999)
{
cout << "The sum is: " << sum << endl;
cout << "The average is: " << sum/ave << endl;
}
break;
this is only a part of the program because it's too long but I think this would be enough for you guys to hel pme.
I think you're ready to make it into a function kind of like this;
1 2 3 4 5 6 7 8 9 10 11 12 13 14
void mTable(int start, int end)
{
for (int x=start; x<=end; x++)
{
cout << x << " ";
}
}
int main()
{
mTable(3, 5);
int wait;
cin>>wait;
}
I'll leave the actual function programming up to you, but in this case you can type mTable(3, 5); and the numbers 3 through 5 will print to screen, or mTable(1, 10) and 1 through 10 will show up.