#include
#include
using namespace std;
int main(){
int nilai;
for(nilai=1;nilai<=10;nilai++)
cout<
system(“PAUSE”);
return EXIT_SUCCESS;
}
Explanation:
- Looping syntax:
for (initialization; conditions; increase)
statement;
- Initialize loop control variables set to their original values.
- The condition is an expression which is tested each time the loop repeats. as long as the conditions are right (not zero) the loop continues to run.
- Increase in the expression that determines how the loop control variable increases each time the loop repeats.
- The program will print the numbers 1 to 10
- Initial value is initialized with a value of 1.
- Each time you repeat, the value <= 10 will be tested.
- If true, the output value will count and increased by one.
- When the count reaches a value greater than 10, the condition becomes false, and the loop will stop running.
Tidak ada komentar:
Posting Komentar