Modify this program/source code by creating a file object and opening the file (ex: ofstream outFile; outFile.open("mult

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Modify this program/source code by creating a file object and opening the file (ex: ofstream outFile; outFile.open("mult

Post by answerhappygod »

Modify this program/source code by creating a file object and
opening the file (ex: ofstream outFile;
outFile.open("multiplicationtable.txt")
(The output should be the same as the photos.)
Modify This Program Source Code By Creating A File Object And Opening The File Ex Ofstream Outfile Outfile Open Mult 1
Modify This Program Source Code By Creating A File Object And Opening The File Ex Ofstream Outfile Outfile Open Mult 1 (81.91 KiB) Viewed 34 times
оор ол Есм 3 4 5 6 7 8 #include <iostream> #include <string> #include <fstream> using namespace std; void displayMultiplicationTable(ofstream &out, int n); void displayAllMultiplicationTable(string fileName); ===”三 Qint main() { displayAllMultiplicationTable("multiplicationtable.txt"); cout << "The output is in the multiplication table text file" << endl; return; avoid displayMultiplicationTable(ofstream& out, int n) { int range = 12; out « n « "X" << endl; 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 CORG for (int i = 1; i <= range; ++i) { out « i « " X " « n « " = " « n * i < endl; out << endl; -D avoid displayAllMultiplicationTable(string fileName) { ofstream out(fileName.c_str()); for (int i = 1; i <= 12; i++) { displayMultiplicationTable(out, i); } out.close();

- 1 2 3 4 5 6 7 1X 1 x 1 = 1 2 x 1 = 2 3 x 1 = 3 4 x 1 = 4 5 x 1 = 5 6 x 1 = 6 7 x 1 = 7 8 x 1 = 8 9 x 1 = 9 10 x 1 = 10 11 x 1 = 11 12 x 1 = 12 oc w 8 9 10 11 12 13 14 15 16 17 18 19 20 21 2x 1 x 2 = 2 2 x 2 = 4 3 x 2 = 6 4 x 2 = 8 5 x 2 = 10 6 x 2 12 7 x 2 = 14 8 x 2 = 16 9 x 2 = 18 10 x 2 = 20 11 x 2 = 22 12 x 2 24 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 ЗХ 1 x 3 = 3 2 x 3 = 6 3 x 3 = 9 4 x 3 = 12 5 x 3 = 15 6 x 3 = 18 7 x 3 21 8 x 3 = 24 9 x 3 = 27 10 x 3 = 30 11 x 3 = 33 12 x 3 = 36 4X 1 x 4 = 4 2 x 4 = 8 3 x 4 = 12 4 x 4 = 16 5 x 4 = 20 6 x 4 = 24 7 x 4 = 28

= 4x 1 x 4 = 4 2 x 4 = 8 3 x 4 = 12 4 x 4 = 16 5 x 4 = 20 6 x 4 = 24 7 x 4 = 28 8 x 4 32 9 x 4 = 36 10 x 4 = 40 11 x 4 = 44 12 x 4 = 48 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 5X 1 x 5 = 5 2 x 5 = 10 3 x 5 = 15 4 x 5 20 5 x 5 = 25 6 x 5 = 30 7 x 5 35 8 x 5 = 40 9 x 5 = 45 10 x 5: = 50 11 x 5 = 55 12 x 5 = 60 6X 1 x 6 = 6 2 x 6 = 12 3 x 6 = 18 4 x 6 = 24 5 x 6 = 30 6 x 6 = 36 7 x 6 = 42 8 x 6 = 48 9 x 6 54 10 x 6 = 60 11 x 6 = 66 12 x 6 = 72 86 = 87 88 89 90 91 7X 1 x 7 = 7 2 x 7 = 14 3 x 7 = 21 4 x 7 = 28 5 x 7 = 35 6 x 7 = 42 7 x 7 = 49 92

12 x 7 = 84 = 8X 1 x 8 = 8 2 x 8 = 16 3 x 8 = 24 4 x 8 = 32 5 x 8 = 40 6 x 8 48 7 x 8 56 8 x 8 = 64 9 x 8 72 10 x 8 = 80 11 x 8 = 88 12 x 8 = 96 = 45 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 9X 1 x 9 = 9 2 x 9 18 3 x 9 = 27 4 x 9 = 36 5 x 9 6 x 9 = 54 7 x 9 = 63 8 x 9 72 9 x 9 = 81 10 x 9 = 90 11 x 9 = 99 12 x 9 = 108 10X 1 x 10 = 10 2 x 10 = 20 3 x 10 = 30 4 x 10 = 40 5 x 10 = 50 6 x 10 = 60 7 x 10 = 70 8 x 10 = 80 9 x 10 = 90 10 x 10 = 100 11 x 10 = 110 12 x 10 = 120 11X 1 x 11 = 11 2 x 11 = 22 3 x 11 = 33 4 x 11 = 44 5 x 11 = 55

3 x 10 = 30 4 x 10 = 40 5 x 10 = 50 6 x 10 = 60 7 x 10 = 70 8 x 10 = 80 9 x 10 = 90 10 x 10 = 100 11 x 10 = 110 12 x 10 = 120 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 11x 1 x 11 = 11 2 x 11 = 22 3 x 11 = 33 4 x 11 = 44 5 x 11 = 55 6 x 11 = 66 7 x 11 = 77 8 x 11 = 88 9 x 11 = 99 10 x 11 = 110 11 x 11 = 121 12 x 11 = 132 12x 1 x 12 = 12 2 x 12 = 24 3 x 12 = 36 4 x 12 = 48 5 x 12 = 60 6 x 12 = 72 7 x 12 = 84 8 x 12 = 96 9 x 12 = 108 10 x 12 = 120 11 x 12 = 132 12 x 12 = 144
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply