how to creat a table using c++

i have written a program that when three integer is entered , it print their sum , product , average , smallest and a largest , so i want help on how can i make it print those in a table form ?

like this

1
2
sum   product    average    smallest     largest  
   4       6                2              1                   2



the example data was not calculated .
Last edited on
You can use setfill / setw manipulators
http://www.cplusplus.com/reference/iostream/manipulators/setfill/ ( the default fill char is a space )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22


// modify showpoint flag
#include <iostream>
using namespace std;

int main () {
  signed int p, z, n;
  p=1;
  z=0;
  n=-1;
  cout <<   showpos << p << '\t' << z << '\t' << n << endl;
  cout << noshowpos << p << '\t' << z << '\t' << n << endl;
  return 0;
}



The execution of this example displays something similar to:

+1      +0      -1
1       0       -1



i am trying to use this but it seems to be complected
Topic archived. No new replies allowed.