"Introduction of While loop"

count=0;
While[count<10,
count=count+1;
Print["Say I can make it for ", count, " times"];
];(*end while*)

Print["Exited While loop. Count is ",count];

"Another example"
"Print out the value of {x,f[x]} while increment x by Deltax begining at x=0, until f[x] exceed a set limit"

f[x_]:=x^2;limit=1.5;Deltax=0.125;

count=0;x=0;
While[f[x]<limit,
count=count+1;
x=x + Deltax;
Print[{count,x,f[x]}];
];(*end while*)
Print["Exited While loop. {count, x, f[x],limit} are ",{count, x, f[x],limit}];
"Note that the last value of f[x] exceed the limit. Can you modify the code so that it  returns only the values of {x,f[x]} not exceeding the limit as set? "

"Use bisection method to find a root for the function. Only one root is found."

"First plot the function and try to find a domain such that you can see the curve cut through the x-axis. Do this via trial and error."
f[x_]:=x^6-x - 1; 
Plot[f[x],{x,-1,1}]

a=-1;b=0;(*define the initial domain [a,b] *)

(*tolerence*)
epsilon=0.001; 


(*initialistation*)
count=0;countvalve=100;
c=0.5*(a+b);

While[Abs[f[c]]>epsilon,
count=count+1;
c=0.5*(a+b);
If[f[c]*f[a]<0,
b=c,
(* else *)
a=c
];
If[count>countvalve,Break[]];(*just in case it does not converge, the while loop can be exited via this 'valve'*)
Print[{count,c,f[c],epsilon}];

];(*end while*)
Print["While loop exited"];
Print[{count,c,f[c],epsilon}];
Plot[f[x],{x,c-0.1,c+0.1}]

"The function contains two roots. How do you find the other one?"