HELP PLEASE:>

i'm trying to debug this, I was able to get it to compile but now there is a problem with the formula
//Displays numbers 1 to 10
// times 2, 3 and 4
// example number doubled tripled quadrupled
// 1 2 3 4
// 2 4 6 8 .....

#include<iostream>
using namespace std;

int main()
{
int num;
const int LIMIT = 10;
cout << "Number Doubled Tripled Quadrupled" << endl;
for(num = 1; num = LIMIT; num++)
cout << " " << num << "\t " << num * 2 << "\t " <<
num * 3 << "t " << num * LIMIT << endl;
return 0;
}
Last edited on
The [/code] part (the one with the slash) needs to come after your code.

Could you explain what the "problem" is? It's difficult to help when we don't know what's wrong.

EDIT: I do note that the comment as the top says you need to multiply by 4 somewhere, but I can't see that in your code. You're also multiplying by 10, which is not what you're supposed to be doing.
Last edited on
For loop looping condition needs to be fixed as well.
Your for loop has one to many = signs. Look at your for loop and look at mine. See the difference?

1
2
3
4
5
for(num = 1; num < LIMIT; num++)
{
	cout << " " << num << "\t " << num * 2 << "\t " << 
	num * 3 << "\t " << num * LIMIT << endl;
}
ok i just got done debugging my other assignments, thanks so much for the help. here is what i got now and it works great
// FIX 5-3
//Displays numbers 1 to 10
// times 2, 3 and 4
// example number doubled tripled quadrupled
// 1 2 3 4
// 2 4 6 8 .....

#include<iostream>
using namespace std;

int main()
{
int num;
int LIMIT= 10 ;
cout << "Number Doubled Tripled Quadrupled" << endl;
for(num=1;num <=LIMIT;num++ )
cout << " " << num << "\t " << num * 2 << "\t " <<
num * 3 <<"\t "<<num * 4<< "\t " << endl;
system("pause");
return 0;
}
i think that if i were to run the for loop with num < LIMIT the loop would stop after running 9 times because 10 is not less than 10. I didn't try it but i think that is what would happen.
Topic archived. No new replies allowed.