CONTROL STRUCTURE IN C++
DO WHILE AGAIN:-
#include
using namespace std;
int main()
{
void display();
display();
cout<<" in main.....";
return 0;
}
void display()
{
void display_inner();
display_inner();
cout<<" within a function 1\n";
}
void display_inner()
{
void display_innermost();
display_innermost();
cout<<"now inside the function 2\n";
}
void display_innermost()
{
cout<<"inner most ...........";
}
DO WHILE BREAK:-
#include
using namespace std;
int main()
{
int i =0,n=5;
do
{
cout <<"hello";
i += 2;
cout<<"c++ hello "<<endl;
i -= 1;
if(i == 5)
{
n=6;
continue;
}
}
while(i<n);
return 0;
}
DO WHILE CONTINUE:-
#include
using namespace std;
int main()
{
int i =0,n=5;
do
{
cout <<"hello";
i += 2;
goto again;
}
while(i<n);
again:
cout<<"c++ hello "<<endl;
return 0;
}
DO WHILE:-
#include
using namespace std;
int main()
{
int i =0,n=5;
do
{
cout <<"hello";
i += 2;
cout<<"c++ hello "<<endl;
i -= 1;
if(i == 3)
break;
}
while(i<n);
return 0;
}
FLAG:-
#include
using namespace std;
int main()
{
bool flag =1;
do
{
cout<<"flag ="<<flag<<endl;
flag=!(flag);
}
while(flag);
return 0;
}
FLAG 2:-
#include
using namespace std;
int main()
{
bool flag =1;
do
{
cout<<"flag ="<<flag<<endl;
!(flag);
}
while(flag);
return 0;
}
FLAG 3:-
#include
using namespace std;
int main()
{
int i =0,n=5;
do
{
cout <<"hello";
i += 2;
cout<<"c++ hello "<<endl;
i -= 1;
}
while(i<n);
return 0;
}
0 comments:
Post a Comment