Tabulated Format Table

I was wandering if someone could give me guidance to my program. I have to display (logx, sqrt, pow(2.0,3), pow(2.0,2)...in a formulated table...I have started already, but im not sure if I am going around it the right way.

do I have to do FOR loops for each math formula...i.e sqrt, pow...im not sure what to do next, if someone could give me a gentle hint I would be grateful...

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
#include	<iostream.h>
#include	<iomanip.h>
#include	<cmath>


int main ( )
{
		int hold;

        cout << setw ( 10 ) << ' X' << setw ( 11 ) <<"sqrt(x)"<< "x ^ 2"<<" x ^ 3\n";
		cout << setw(21) << "=================================================\n";

		cout << setprecision ( 4 ) ;

		for	( int  x = 2 ;	x <= 10 ;  ++ x )
			cout << setw ( 10 ) << x << setw ( 10 )
				<< sqrt ( x );"\n" ;
				
				
				

		cout << setw(21) << "==================================================\n";
		cin >> hold;                 // Just to hold screen up
		return ( 0 ) ;
} 
closed account (S6k9GNh0)
I can't really understand your intentions. You say you need to display (logx, sqrt, pow(2.0,3), pow(2.0,2), but wtf is that supposed to mean?
Use a for loop like.......

1
2
3
4
5
6
7
cout<<"x\t\t"<<"log10(x)\t\t"<<"sqrt(x)\t\t"<<"pow(2,x)\t\t"<<endl;
cout<<"------------------------------------------------------------------"<<endl;
double i=0.0;
for (int i=0;i<20;i++)
{
cout<<setprecision(4)<<i<<"\t\t"<<log10(i)<<"\t\t"<<sqrt(i)<<"\t\t"<<pow(2.0,i)<<endl;
}

......will build a 20 row by 4 col table.
Aww thank you so much buffbill...thats all i wanted was a table to display the output for the formulas in sqrt,pow and log x...thanks very much ;-)
Topic archived. No new replies allowed.