Search This Blog

Tuesday, 18 March 2014

use of goto in C++


// print triangular star using "goto" statement
#include<iostream.h>
#include<conio.h>
void main()
{
int j,i;
i=1;
x:
j=1;
y:
cout<<"*";
j++;
if(j<=i)
goto y;
cout<<endl;
i++;
if(i<=5)
goto x;
getch();
}

Output

No comments:

Popular Posts