Recap - Pretty Print Array
Part of the Fundamentals section of Coddy's C++ journey — lesson 61 of 74.
Challenge
EasyCreate a program that:
- Receives
n: the number of elements in the array - Then receives
nstrings to populate the array
Print the array beautifully in the following format:
[elem1, elem2, elem3, ...]Try it yourself
#include <iostream>
int main() {
int n;
std::cin >> n;
std::cin.ignore();
std::string arr[n];
for (int i = 0; i < n; i++) {
std::string val;
std::cin >> val;
arr[i] = val;
}
// Print the array beautifully
return 0;
}All lessons in Fundamentals
4Operators Part 1
Arithmetic OperatorsModulo OperatorIncrement/DecrementPost Increment/DecrementArithmetic ShortcutsComparison OperatorsString Comparison5Operators Part 2
Logical Operators Part 1Logical Operators Part 2Recap - Simple LogicLogical Operators Part 311Arrays Basics
Declaring ArraysAccessing ElementsModifying ElementsRecap - Pretty Print ArrayArrays And FunctionsRecap - Product ArrayRecap - Reversed ArrayEnhanced For LoopCommon Array Operations3Variables Part 2
Type DeclarationNaming ConventionsRecap - Initialize VariablesType Casting Part 1Type Casting Part 26Decision Making
If StatementIf - ElseSwitch StatementConditional OperatorRecap - If ElseNested If - Else