hello my problem is as you can see while x is equals to n+1/2 the first while works; and for example it increases x by 1 . then the second while works because the program works from top to bottom.I dont want them work both. I want my program to return just above the first while after one of these whiles works. How can i do it? thanks for help
hello my problem is as you can see while x is equals to n+1/2 the first while works
The condition of the first while is not specified to check for equality. It's checking for assignment. As long as something is being transferred to x, it will return true.
while(x=(n+1)/2)
= is not equality. The first while loop is not working as intended, the second one is.
Edit: Never mind that seems to work as you describe. I don't really understand what you're trying to ask though. What is the actual code any way?
I think he's straight up assuming that both while loops will work on every run, but he doesn't want that. He wants the program to run only one while loop, either the first or second one, and after that return the result of the first loop.