what am i doing wrong here?

I am doing a project for class and since I am not allowed to share/post it so i made an example of the part that I am stuck on. Idk what i am doing wrong here...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <cmath>
using namespace std;

void test(int a, int n){
    a=3;
    n=4;
    for(int i=1; i<=n; ++i){
        cout<<i;
        int ex=a*pow(10,i);
        cout<<"i="<<i<<", pnt("<<a<<"*10^"<<i<<")="<<ex<<endl;
    }
}



int main(){
    cout<<test;
}
Last edited on
I dont know what the code is supposed to be doing; however, I make some recommendations.
Link to Functions tutotial:
http://www.cplusplus.com/doc/tutorial/functions/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <cmath>
using namespace std;

void test(int a, int n) {
	//a = 3;
	//n = 4;
	for (int i = 1; i <= n; ++i) {
		cout << i;
		double /*int*/ ex = a * pow(10, i);
		cout << "i=" << i << ", pnt(" << a << "*10^" << i << ")=" << ex << endl;
	}
}



int main() {
	test(3, 4);
	//cout << test;
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
#include <cmath>
using namespace std;

void test(int a, int n){
    for(int i=1; i<=n; ++i){
        cout<<i;
        int ex=a*pow(10,i);
        cout<<"i="<<i<<", pnt("<<a<<"*10^"<<i<<")="<<ex<<endl;
    }
}



int main(){
    test(3,4);
}



1i=1, pnt(3*10^1)=30                                                             
2i=2, pnt(3*10^2)=300                                                            
3i=3, pnt(3*10^3)=3000                                                           
4i=4, pnt(3*10^4)=30000 


How come they are all numbered?
How come they are all numbered?


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <cmath>
using namespace std;

void test(int a, int n) {
	//a = 3;
	//n = 4;
	for (int i = 1; i <= n; ++i) {
		//cout << i;
		double /*int*/ ex = a * pow(10, i);
		cout << "i=" << i << ", pnt(" << a << "*10^" << i << ")=" << ex << endl;
	}
}



int main() {
	test(3, 4);
	//cout << test;
}


Like this?

i=1, pnt(3*10^1)=30
i=2, pnt(3*10^2)=300
i=3, pnt(3*10^3)=3000
i=4, pnt(3*10^4)=30000
On your code, line 7 is
cout << i;


Just take the portion of the code out.
damn i didn't even realized i had that, must have done it by accident, ty.
Topic archived. No new replies allowed.