Answer to Question #201360 in C++ for Fisher Joker

Question #201360

critically explain why you would consider arrays over normal data 

types AP[5 marks]

b. from your explanation in “a” above, define and initialize an array called 

BongoBar of type string and having 4 elements. CR[5 marks]

c. embed your array in “b” above in a full c++ program and display each 

of the initialized data when your program executes. CR [5 marks]

d. critically explain what will happen if an amateur programmer decides to 

called BongoBar[5] in the main function in your program in “c” above.


1
Expert's answer
2021-06-01T03:00:11-0400

(a) The question is not clear, the answer to it depends on its context.


// (b)
std::string BongoBar[4] = {"Bon", "Go", "Bar", "4"};


// (c)
#include <iostream>

using namespace std;

int main() {
  std::string BongoBar[4] = {"Bon", "Go", "Bar", "4"};
  for (int i = 0; i < BongoBar.length; i++) {
    std::cout << BongoBar[i] << std::endl;
  }
  return 0;
}


(d) It will just output all the elements of this array.


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog