-system was not declared, you must include the cstdlib if you plan to use it.
-if_statement isn't testing anything.
-As other folks have said, i+=5 should work; spoiler implementation below.
Use the code tags next time please.
Spoiler Example:
1 2 3 4 5 6 7 8 9 10 11 12 13
#include<iostream>
usingnamespace std;
int main()
{
int i;
for(i=4;i<=24;i+=5)
{
cout<<i<<endl;
}
cout<<"\nPress Enter to exit"<<endl;
cin.get();
return 0;
}
@Dput: while I understand you were making minimal corrections to the code to make it work, you should at least fix the other poor practices while you are at it ;)
#include<iostream>
int main(){
for(int K=4; K<=24; K+=5)
std::cout << K << ' ';
std::cout << '\n';
return 0;
}
- limit the scope of the variables. Given that the counter is only used in the loop, it should only live in the loop.
- std::endl would flush the stream, which is not necessary. Could be replaced with '\n', but that would be wrong too.
The assignment ask the output to be: 4 9 14 19 24, separated with spaces.
The last newline is so the command prompt starts at the beginning.
- The program should terminate when it ends, no wait for a key press.