انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة

lesson 10

الكلية كلية العلوم للبنات     القسم قسم الحاسبات     المرحلة 1
أستاذ المادة ماجد جبار جواد الفنهراوي       10/03/2018 19:46:22
Controlling Statements:
For effective handling of the loop statements, C++ allows the use of the following two types of control break statements:
1. Break Statement
The break statement terminates the loop (for, while and do...while loop) and switch statement immediately when it appears.
- Syntax of break
break;

2. Continue Statement
It is sometimes necessary to skip some statement/s inside the loop. In that case, continue statement is used in C++ programming.
- Syntax of continue
continue;
In practice, continue statement is usually used inside conditional statement.
Goto Statement:
The goto statement is used to alter the program execution sequence by transferring the control to some other part of the program.
- Syntax of goto
The syntax of a goto statement in C++ is ?
goto label;
..
.
label: statement;
Where label is an identifier that identifies a labeled statement. A labeled statement is any statement that is preceded by an identifier followed by a colon (:).

int main ()
{
int a = 10;
LOOP:do
{
if( a == 15)
{
// skip the iteration.
a = a + 1;
goto LOOP;
}
cout << "value of a: " << a << endl;
a = a + 1;
} while( a < 20 );
return 0;
}
When the above code is compiled and executed, it produces the following result ?
Output
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 16
value of a: 17
value of a: 18
value of a: 19

المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .