Thursday 29 September 2016

FOR LOOP IN C++

CODINGCLASSES|LEARNTOPROGRAM


FOR LOOP IN C++:-

THIS IS ALWAYS IN FOR LOOP IN EVERY PROGRAMM IN C++ LETS CHECK OUT THE EXAMPLE FOR LOOP

*INSTIALIZATION

**CONDITION

***ITERATION

SYNTAX FOR LOOP

For( i=0;  i<n;   i++ )

e.g

#include<iostream.h>
#include<conio.h>
void forloop()
{
int i,n;
cout<<"Enter the number from the own wish ";
cin>>n <<endl;
for(i =0; i<n; i++)
{
cout<<i <<endl;
}
}
void main()
{
forloop();
getch();
}
O/P :-
Enter the number n=5
0,1,2,3,4

                                                       or
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,n;
cout<<" Enter the number";
cin>>n<<endl ;
for(i=0; i<n; i++)
{
cout<<" i"<<check out the next post;
}
getch();
}

o/p-
Enter the number n=10
    ,0,1,2,3,4,5,6,7,8,9

This programme having no any compile time and run time error It is already checked in Turbo c++ and c Free

No comments:

Post a Comment