CONTROL STRUCTURE IN C++
DO WHILE AGAIN:-
#include<iostream>
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<iostream>
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<iostream>
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<iostream>
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<iostream>
using namespace
std;
int main()
{
bool flag =1;
do
{
cout<<"flag
="<<flag<<endl;
flag=!(flag);
}
while(flag);
return 0;
}
FLAG 2:-
#include<iostream>
using namespace
std;
int main()
{
bool flag =1;
do
{
cout<<"flag
="<<flag<<endl;
!(flag);
}
while(flag);
return 0;
}
FLAG 3:-
#include<iostream>
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;
}
CONTROL STRUCTURE IN C++
Reviewed by Marketing Thrills
on
September 15, 2015
Rating:
No comments:
Post a Comment