CSE 283 Introduction to Object Oriented Design

Barbara Nostrand, Ph.D.


 
 

C++ Lining up Numbers Program

Prev | Next | Help Pages

#include <iomanip>
#include <iostream>

int main() { cout << setiosflags(ios::fixed); // only needed once for (int i=1; i <= 7; i++) { cout << i << " "; cout << setprecision(i) << setw(10) << 1.23456 << endl; // need both every time } }


Produces this output:

1        1.2
2       1.23
3      1.235
4     1.2346
5    1.23456
6   1.234560
7  1.2345600

Prev | Next | Help Pages

 
  Home

FAQ

Help

Labs

Policies

Schedule

XEmacs

UNIX

C++ main 1

C++ main 2

C++ Strings

C++ Algorithms

C++ Vector

C++ Numbers

Package java.io

Package java.awt

Package javax.swing

Java GUI Tutorial




Last modified: 2007 SEP 09
bnostran@syr.edu