Lecture 137
// Loop GoTo
#include
<iostream>
#include
<conio.h>
using
namespace std;
main ()
{
int i;
i=1;
cout<<"Odd number:
";
Loop1: //Label
cout<<i<<" ";
i+=2;
if(i>=10)
goto Loop2;
goto Loop1;
Loop2:
getch();
return 0;
}
Output:
Code:
// Loop GoTo
#include
<iostream>
#include
<conio.h>
using
namespace std;
main ()
{
int i;
i=1;
cout<<"Odd number:
";
Loop1: //Label
cout<<i<<" ";
i+=2;
if(i==10)
goto Loop2;
goto Loop1;
Loop2:
getch();
return 0;
}
Output: