Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Fill in code to have following outout: abcde fghij klmno pqrst uvwxy code: #incl

ID: 3574362 • Letter: F

Question

Fill in code to have following outout:

abcde

fghij

klmno

pqrst

uvwxy

code:

#include <iostream>
#include <string>
#include <vector>
using namespace std;

string characters = "abcdefghiklmnopqrstuvwxy";
vector< vector<char> > grid;

for (int i = 0; i < 5; i++) {
   vector<char> temp;
   for (int j = 0; j < 5; ++j) {


   }
   grid.push_back(temp);
}

for (int i = 0; i < 5; ++i) {
   for (int j = 0; j < 5; ++j) {
       cout << grid.at(i).at(j);
  
  
   }

}

Explanation / Answer

//c++ code
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main()
{
   string characters = "abcdefghijklmnopqrstuvwxy";
   vector< vector<char> > grid;

   for (int i = 0; i < characters.size(); i=i+5)
   {
        vector<char> temp;
        for (int j = i; j < (i+5); ++j)
        {
           temp.push_back(characters[j]);
        }
        grid.push_back(temp);
   }

   for (int i = 0; i < 5; ++i)
   {
        for (int j = 0; j < 5; ++j)
        {
            cout << grid.at(i).at(j);
      
        }
        cout << endl;

   }
   return 0;
}

/*
output:

abcde
fghij
klmno
pqrst
uvwxy


*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote