From c4ad506b9e207a4056ba8e46b21549fa80282a21 Mon Sep 17 00:00:00 2001 From: aryanaces <43854758+aryanaces@users.noreply.github.com> Date: Thu, 4 Oct 2018 22:47:14 +0530 Subject: [PATCH] Added comments to the code for explanation I have added some comments to the code which will make it easy for the visitor to understand the syntax of the for loop . And also a comment added explains the function of loop . --- for/src/for.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/for/src/for.cpp b/for/src/for.cpp index a972f35..aad5c72 100644 --- a/for/src/for.cpp +++ b/for/src/for.cpp @@ -3,17 +3,18 @@ // Author : John Purcell // Version : // Copyright : Your copyright notice -// Description : Hello World in C++, Ansi-style +// Description : for looping statement //============================================================================ #include using namespace std; - +// for is a looping statement. Loop statements are used to execute a set of instructions repeated number of times till the time a condition is met . int main() { - for (int i = 0; i < 10; i++) { + for (int i = 0; i < 10; i++) // The syntax of for loop is - for( initialising_statement ; condition ; update expression for looping variable (i in this case)) + { - cout << "Hello " << i << endl; + cout << "Hello " << i << endl; // This is the body of the loop ^^ } return 0;