Skip to main content

Simple For Loop Example Program In C++

Definition

In C++ for loop statement which allow code to be repeatedly executed mainly for loop is 
classified as an iteration statement .
LEARN C++ IN SIMPLE MANNER BUY THIS BOOK
Coded by := Tinku Gupta

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
            // variable declaration
            int b,counter;

            // Get input through Keyboard
cout<<"Enter the number:";
cin >>b;

// using for loop block
for(counter = 1; counter <=b; counter++)
            {
                cout << "execute" << counter   << " time " << endl;

            }
            getch();
            return 0;


}

OUTPUT

Enter the number:5
execute 1 time
execute 2 time
execute 3 time
execute 4 time
execute 5 time

Comments

Popular posts from this blog

C++ Program Finding The Absolute Value

#include<iostream> using namespace std; int main() { cout<<" enter any number"; cin>>num; if(num>0) { cout<<"The absolute value of number is:"<< num; } else { cout<<"The absolute value of number is :"<< -(num); } return 0; } OUTPUT Enter Any number: 2 The absolute value of number is 2