Week 10 PDF
Week 10 PDF
Muhammad Kamran
Lecturer Civil Engineering Department
Sarhad University of Information and Technology
“while” LOOP
Simplest loop of C++ Language.
count = 0;
Loop
false false
Continuation (count < 100)?
Condition?
true true
Statement(s) cout << "Welcome to C++!\n";
(loop body) count++;
(a) (b)
Declare count
Trace for Loop And Variable initialized
count is now 0
Print Welcome
int count =0; to C++
while (count < 2)
{
cout << "Welcome to C++\n";
count++;
}
Trace for Loop
Print Welcome
int count =0; to C++
while (count < 2)
{
cout << "Welcome to C++\n";
count++;
}
Trace for Loop