[英]While Loop and If Statements and functions
I don't know how to continue the loop indefinitely by only closing when I hit 'n' or 'N'... Once I put anything it eventually closes so how do I get back into the loop? 我不知道如何无限期地仅通过在我按下“ n”或“ N”时闭合才继续循环。一旦我放了东西,它最终就会闭合,那么我如何回到循环中?
int counter = 5;
while(counter > 1)
linear(xcoordinateone, xcoordinatetwo, ycoordinateone, ycoordinatetwo, slope, intercept); //calling
{
cout<<"The points you entered define the function: y = " << slope << xone << "+" << intercept;
cout << "\n Do you want to continue?";
if (answer == 'N' || answer == 'n');
cin >> answer;
return 0;
}
You can but multiple conditions in your while loop: 您可以在while循环中添加多个条件:
answer = 'y';
while(answer != 'N' && answer != 'n'){
cout << "\n Do you want to continue?";
cin >> answer;
}
do {
// do stuff
cout << "\n Do you want to continue?";
cin >> answer;
} while (answer!='N' && answer!='n');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.