Help Aligning Function Outputs

when i run my code i want each function to be displayed side by side from left to right and i cant figure out how to do it. also cant figure out how to make the numbers right justified. any help is appreciated. Thanks

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <cmath>
#include <windows.h> 

using namespace std;

void ClearTheScreen();
void Heading();  
void NormalTermination();
void K();
void SquareRoot();
void Cube();
void CubeRoot();

int main()
{
	Heading();		
	K(); 
	SquareRoot();
        Cube();
	CubeRoot();
   

	return 0;
}

void ClearTheScreen()
{
	system("cls");
}


void Heading()	
{
	ClearTheScreen();		
	cout << "\t\t    xxxxxxx xxxxxxx xxxxxxxxx xxxxxxxx";
	cout << "\n\t\t\t\t xxxxxxx xxxxxxx";
	cout << "\n\n\t\t\t\t     CS xxx";
	cout << "\n\t\t\t\t  Beginning C++";
	cout << "\n\n\t\t\t\t  xxxxxxx xxxxx\n\n   ";
	
}

void NormalTermination()
{
	cout << "\n\t\t\t";
}

void K()
{
	int k;
	cout << "\t\tk";
	k = 0;		
	while ( k < 15 )
	{
		cout << "\t\t    ";
		
		cout  <<"\n\t\t"<< k+1<< right << setw(12)<< endl;
		k++;
	}
	
}

void SquareRoot()
{
	int n;
	cout << "\tsqrt";
	n = 0;	
	while ( n < 15 )
	{
		cout << "\t\t\t    ";
		cout  << "\n\t\t      "<< sqrt (n+1.0);
		n++;
	}
}

void Cube()
{
	int k;
	cout << "\t\t\t\t   cube\n\n";
	k = 0;		
	while ( k < 15 )
	{
		cout << "\t\t\t\t    ";
		cout << "\n"<< pow(k+1.0,3);
		k++;
	}
}

void CubeRoot()
{
	int k;
	cout << "\t\t\t\t\t   cube root\n\n";
	k = 0;		
	while ( k < 15 )
	{
		cout << "\t\t\t\t\t    ";
		cout << "\n"<< pow(k+1.0,1.0/3);
		k++;
	}
}
Last edited on
Topic archived. No new replies allowed.