Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

how to print an array in cpp in single line

int Grades[5] = { 3, 2, 5, 2 };

cout << "Grades: ";
for (int i = 0; i < sizeof(Grades)/sizeof(int); i++) {
    cout << Grades[i] << ", "; //minus the commas, remove (<< ", ") or to space out the grades, just remove the comma
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #print #array #cpp #single #line
ADD COMMENT
Topic
Name
7+3 =