Do - While Loop

In the while loop test expression is evaluated at the beginning of loop where, in case of do while loop, test, expression is evaluated at the end of loop. Following program illustrate this.


void main()
{
int n,sqr;
char reply='y';
do
{
cout<<"Enter a no";
cin>>n;
sqr=n*n;
cout<<"Square of a no is"<cout<<"Do you want to find square of another no(y/n)?";
cin>>reply;
}while(reply!='n');
}

No comments:

Post a Comment