+ 3
why is the output wrong??
sooo , shouldn't this program give me the multiple of a and b? what did i do wrong here? #include <iostream> using namespace std; int main() { int a,b,c,i =0; cout << "insert an integer : "; cin >> a; cout << endl << "insert another : "; cin >> b; for (i=0; i >= b; i = i+1) { c = a+c; } cout << a << "x" << b << "=" << c; return 0; }
8 Answers
+ 3
The condition part of the for loop is false from the beginning. You would only need to change >= to <.
+ 2
thank you
that was so stupid of međ
+ 2
Rather do: int a,b,c=0,i;
+ 2
oh , i thought all four variables would be initialized as 0 with this.
thank you for taking the time to teach me.
+ 1
i did initialize c in this line
int a,b,c,i =0;
+ 1
endl ( in line 8th) must be end of statemant
and the conditions in your for loop is wrong ( line 10th)