Write a function DisplayFormatted() with the following header:
voidDisplayFormatted (int n, int Width)
/*Displays the value of n left-aligned in a field of size Width.
Post: Value displayed left-aligned in a field of size Width.*/
Write a program illustrating its use.
Overload the DisplayFormatted() function to work for double values. In this case, include a width parameter and also a decimals parameter giving the number of decimals to display.
Write a program illustrating both DisplayFormatted() functions.
Add these functions to the utility library.
here is a bit of code that I have written:
#include "Stdafx.h"
#include <iostream>
using namespace std;
void DisplayFormatted(int n, int width)
{
for (int i = 0; i <= width; i = i +1)
cout <<" ";
cout <<n <<endl;
}
int main()
{
int n;
int width;
cout <<"Enter number: ";
cin >> n;
cout <<"enter width: ";
cin >> width;
DisplayFormatted(n,width);
system("pause");
return 0;
}