Computer Science, asked by ahana14, 1 year ago

C++ loops format :
a) for loop
b) while loop
C) do while loop

Answers

Answered by hargovind19pb3g71
0
for var=x to y :statement:next
Do while x=n
Loop

Dowhile true
Statement
Answered by Soñador
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