C++ loops format :
a) for loop
b) while loop
C) do while loop
Answers
Answered by
0
for var=x to y :statement:next
Do while x=n
Loop
Dowhile true
Statement
Do while x=n
Loop
Dowhile true
Statement
Answered by
8
Answer:
Formats for the types of loop are as follows:
For loop :
#include<iostream.h>
#include<conio.h>
void main( )
{
clrscr( );
int i[5];
for(i=1;i<=5;i++)
{
cout<<"Hello World"<<endl;
}
getch( );
}
Output
Hello World
Hello World
Hello World
Hello World
Hello World
While loop:
#include<iostream.h>
#include<conio.h>
void main( )
{
clrscr( );
int i = 1;
while (i < 5)
{
cout<<"Hello World";
i++;
}
getch( );
}
Output
Hello World
Hello World
Hello World
Hello World
Hello World
Do While loop:
#include<iostream.h>
#include<conio.h>
void main( )
{
clrscr( );
int i = 1;
do
{
cout<<"Hello World";
i++;
}while (i < 5);
getch( );
}
Output
Hello World
Hello World
Hello World
Hello World
Hello World
Similar questions
English,
7 months ago
Social Sciences,
7 months ago
English,
7 months ago
English,
1 year ago
Accountancy,
1 year ago