these are my instructions: a) [countup] Count up to a Limit specified by the user, starting at 1.
Output format: COUNT UP: 1 2 3 4 5 6 7 8 9 10
Pseudo-code:
Read a value for Limit (int)
Print the output label (no endline or \n).
Initialize count to 1;
Print count 1,2, ..., Limit // MUST USE for loop
Use following TEST DATA: 3, 0, 13
and this is what ive tried:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
#include <cmath>
usingnamespace std;
int main ()
{
int i = 0;
for (int i; i < 9999; i++)
cin >> i;
cout << i << endl;
return 0;
}
#include <iostream>
#include <cmath>
usingnamespace std;
int main ()
{
int i = 0;
cin >> i;
for (int i; i++; i < (i + 1) )
cout << i << endl;
return 0;
}
Variable i inside the control statement of the loop is not initialized. And as I think i is always less than i + 1 until i will not reach maximum value.:)
#include <iostream>
#include <cmath>
usingnamespace std;
int main ()
{
int i = 1, c;
cout<<"Enter a Number : " ;
cin >> c;
cout << "COUNT UP: ";
for (int i = 1; i < (c + 1); i++ )
cout<< i << " ";
return 0;
}