I need help formatting this multiplication table for this program.?
-
Write a program that generates multiplication tables for the user. The program will ask the user for a number and generate a multiplication table for that number using nested loops. it suppose to look like this if i enter the number 4 1 2 3 4 ----|----|----|----| 1| 1| 2| 3| 4| -|----|----|----|----| 2| 2| 4| 6| 8| -|----|----|----|----| 3| 3| 6| 9| 12| -|----|----|----|----| 4| 4| 8| 12| 16| -|----|----|----|----| heres my code: #include <iomanip> #include <iostream> #include <string> using namespace std; int main() { char Selection; int num = 0; int number = 0; do { cout << "MENU\n"; cout << "a) Generate Multiplication Table\n"; cout << "q) quit program\n"; cout << "Please make a Selection:\n"; cin >> Selection; if(Selection == 'a') { cout << "Please enter a number to generate a multiplication table\n"; cin >> number; for(int i = 1; i <= number; i++) { for (int j = 1; j <= number; j++) { cout << fixed << setw(4) << "---" << setw(2) << i*j << "\n"; } } } else if(Selection != 'a'|| Selection != 'q') { cout << "invalid selection"; } else if(Selection == 'q') { cout<< "quit the program"; } }while(Selection != 'q'); system("PAUSE"); return 0; }
-
Answer:
Try declaring variables on a single line.
David at Yahoo! Answers Visit the source
Other answers
Try declaring variables on a single line.
Related Q & A:
- I need help on what I need to buy or do.Best solution by Yahoo! Answers
- I need help with some horse questions, can you help me.Best solution by Yahoo! Answers
- I did something really bad and now i need help please help me.Best solution by Yahoo! Answers
- I need help with a song I heard.Best solution by Yahoo! Answers
- I am planning a trip to El Salvador and I need help.Best solution by nomadicmatt.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.