0
While Loop
Does the while loop only work with int variables? Thanks beforehand for the answer:)
3 odpowiedzi
0
No, while loop working while condition is true. The type of the variables can be the type you want.
for example
---
string a = "aab";
while (a != "aaa")
{
//change your a-variable to "aaa" and program will quit from loop.
}
+ 1
As Tony Loa explained, while looks for the condition to be true. So you can do While loops with: bool, int, double, float, byte, etc. Yet with a string (imagine that the user should input an exact phrase an the program ask until it as been changed: "continue? y" if "n" or another exit)
0
well if you want to be literal, while loop only works with boolean variables :p