C++ program that use the setw() function to align text on the screen
Posted by Samath
Last Updated: April 06, 2022

Write a program that produces the following output:
**********************************
*   Programming Assignment 1     *
*    Computer Programming 1       *
*         Author: ???                         *
*   Due Date: Monday April. 4       *
**********************************

Code:

#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
  cout << "**********************************" << endl;
  cout << "*" << setw(28) << "Programming Assignment 2" << setw(5) << "*" << endl;
  cout << "*" << setw(27) << "Computer Programming 2" << setw(6) << "*" << endl;
  cout << "*" << setw(21) << "Author: Name???" << setw(12) << "*" << endl;
  cout << "*" << setw(29) << "Due Date: Monday April. 4" << setw(4) << "*" << endl;
  cout << "**********************************" << endl;
  
  return 0;
}
Related Content