Which lines of the following code contain compilation errors, if any?
#include <iomanip>
#include <iostream>

using namespace std;

int main()
{
   const int size = 5;  // 1
   char name[size];  // 2

   cout << "Enter your name: ";
   cin >> setw(size) >> name;  // 3
   cout << "Hello, " << name << "! "  // 4
       "Welcome to C++" << endl;  // 5

   return 0;
}
Explanation
std :: setw - sets the number of characters to be used as the field width for the next insertion operation.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes