NOTE : -
THIS CONTENT IS NOT ORIGINAL
33. An example of formatted output
This program performs formatted output two different ways. Please note the width() and setw() MODIFIERS are only effective on the next item output to the stream. Subsequent items will not be influenced.
You now have a basic knowledge about C++. Inside good books you will learn many more things. The file management system is very powerful, it has many other possibilities than those illustrated here. There is also a lot more to say about classes: template classes, virtual classes...
In order to work efficiently with C++ you will need a good reference book, just like you need one for C. You will also need information on how C++ is used in your particular domain of activity. The standards, the global approach, the tricks, the typical problems encountered and their solutions... The best reference is of course the books written by Bjarne Stroustrup himself (I don't recall which of them I read). The following book contains almost every detail about C and C++ and is constructed in a way similar to this text
This program performs formatted output two different ways. Please note the width() and setw() MODIFIERS are only effective on the next item output to the stream. Subsequent items will not be influenced.
using namespace std;
#include
#include
int main ()
{
int i;
cout << "A list of numbers:" << endl;
for (i = 1; i <= 1024; i *= 2)
{
cout.width (7);
cout << i << endl;
}
cout << "A table of numbers:" << endl;
for (i = 0; i <= 4; i++)
{
cout << setw(3) << i << setw(5) << i * i * i << endl;
}
return 0;
}
| Output |
| A list of numbers: 1 2 4 8 16 32 64 128 256 512 1024 A table of numbers: 0 0 1 1 2 8 3 27 4 64 |
You now have a basic knowledge about C++. Inside good books you will learn many more things. The file management system is very powerful, it has many other possibilities than those illustrated here. There is also a lot more to say about classes: template classes, virtual classes...
In order to work efficiently with C++ you will need a good reference book, just like you need one for C. You will also need information on how C++ is used in your particular domain of activity. The standards, the global approach, the tricks, the typical problems encountered and their solutions... The best reference is of course the books written by Bjarne Stroustrup himself (I don't recall which of them I read). The following book contains almost every detail about C and C++ and is constructed in a way similar to this text
BIBILOGRAPHY / REFERENCE : - http://www.4p8.com/eric.brasseur/cppcen.html
