Podcast
Questions and Answers
ما هي الوظيفة الرئيسية للجمل الشرطية في البرمجة؟
ما هي الوظيفة الرئيسية للجمل الشرطية في البرمجة؟
- إجراء العمليات الحسابية
- تحديد نوع المتغيرات
- التحكم في مسار تنفيذ البرنامج بناءً على شروط معينة (correct)
- تعريف الدوال
متى يتم تنفيذ الأوامر الموجودة داخل كتلة if
؟
متى يتم تنفيذ الأوامر الموجودة داخل كتلة if
؟
- عندما يكون الشرط `false`
- دائماً
- عندما يكون الشرط `true` (correct)
- عند تعريف المتغيرات
ماذا يحدث إذا كان هناك جملة if
بدون else
وكان الشرط false
؟
ماذا يحدث إذا كان هناك جملة if
بدون else
وكان الشرط false
؟
- يتم تنفيذ كتلة `if`
- يتوقف البرنامج عن العمل
- يحدث خطأ في البرنامج
- يتم تجاهل كتلة `if` ويستمر البرنامج في التنفيذ (correct)
أي من العبارات التالية تصف بشكل صحيح استخدام if...else
؟
أي من العبارات التالية تصف بشكل صحيح استخدام if...else
؟
ما الغرض من استخدام المعاملات المنطقية في جملة if
؟
ما الغرض من استخدام المعاملات المنطقية في جملة if
؟
ما هي الجملة الشرطية المتداخلة؟
ما هي الجملة الشرطية المتداخلة؟
ما هي وظيفة جملة switch
؟
ما هي وظيفة جملة switch
؟
في جملة switch
، ما هي وظيفة الكلمة المفتاحية break
؟
في جملة switch
، ما هي وظيفة الكلمة المفتاحية break
؟
في جملة switch
، ما هي وظيفة الكلمة المفتاحية default
؟
في جملة switch
، ما هي وظيفة الكلمة المفتاحية default
؟
أي أداة تستخدم لعرض قائمة خيارات للمستخدم لاختيار واحد منها فقط؟
أي أداة تستخدم لعرض قائمة خيارات للمستخدم لاختيار واحد منها فقط؟
أي أداة تستخدم لعرض قائمة خيارات للمستخدم لتحديد ما يريده منها؟
أي أداة تستخدم لعرض قائمة خيارات للمستخدم لتحديد ما يريده منها؟
ما هي وظيفة أداة مجموعة الأزرار؟
ما هي وظيفة أداة مجموعة الأزرار؟
ماذا يحدث عند استخدام عامل المساواة (=) مرة واحدة بدلاً من عامل المساواة (==) مرتين في جملة if
؟
ماذا يحدث عند استخدام عامل المساواة (=) مرة واحدة بدلاً من عامل المساواة (==) مرتين في جملة if
؟
إذا كان لدينا متغير رقمي باسم score
، كيف نختبر ما إذا كانت قيمته أكبر من أو تساوي 60؟
إذا كان لدينا متغير رقمي باسم score
، كيف نختبر ما إذا كانت قيمته أكبر من أو تساوي 60؟
كيف نجمع بين شرطين باستخدام العامل المنطقي AND
في جملة if
؟
كيف نجمع بين شرطين باستخدام العامل المنطقي AND
في جملة if
؟
ماذا تعني قيمة الخاصية True
للخاصية Checked
لمربع الاختيار؟
ماذا تعني قيمة الخاصية True
للخاصية Checked
لمربع الاختيار؟
كيف نُعلن عن متغير نصي عام باسم userName
؟
كيف نُعلن عن متغير نصي عام باسم userName
؟
ما الغرض من استخدام Parse
؟
ما الغرض من استخدام Parse
؟
ما الغرض من استخدام الفئة Font
؟
ما الغرض من استخدام الفئة Font
؟
أي من العبارات التالية تستخدم بشكل صحيح للتحقق من أن قيمة المتغير password
تساوي "Secret"؟
أي من العبارات التالية تستخدم بشكل صحيح للتحقق من أن قيمة المتغير password
تساوي "Secret"؟
أي مما يلي يُعتبر مثالاً لجملة if
متداخلة بشكل صحيح؟
أي مما يلي يُعتبر مثالاً لجملة if
متداخلة بشكل صحيح؟
في بيئة تطوير Windows Forms، أي عنصر تحكم يستخدم لتمكين المستخدم من تحديد خيار واحد من بين مجموعة خيارات مختلفة؟
في بيئة تطوير Windows Forms، أي عنصر تحكم يستخدم لتمكين المستخدم من تحديد خيار واحد من بين مجموعة خيارات مختلفة؟
في بيئة تطوير Windows Forms، أي عنصر تحكم يسمح للمستخدم بتحديد خيارات متعددة في الوقت نفسه؟
في بيئة تطوير Windows Forms، أي عنصر تحكم يسمح للمستخدم بتحديد خيارات متعددة في الوقت نفسه؟
ما هي الخاصية التي تحدد ما إذا كان عنصر التحكم متاحًا للاستخدام في بيئة تطوير Windows Forms؟
ما هي الخاصية التي تحدد ما إذا كان عنصر التحكم متاحًا للاستخدام في بيئة تطوير Windows Forms؟
ما هي الخاصية التي تحدد ما إذا كان عنصر التحكم مرئيًا في بيئة تطوير Windows Forms؟
ما هي الخاصية التي تحدد ما إذا كان عنصر التحكم مرئيًا في بيئة تطوير Windows Forms؟
ما هي وظيفة عنصر تحكم GroupBox في بيئة تطوير Windows Forms؟
ما هي وظيفة عنصر تحكم GroupBox في بيئة تطوير Windows Forms؟
كيف تحدد لون خلفية عنصر تحكم مربع النص (TextBox) إلى الأحمر في بيئة تطوير Windows Forms؟
كيف تحدد لون خلفية عنصر تحكم مربع النص (TextBox) إلى الأحمر في بيئة تطوير Windows Forms؟
ما هو الغرض من الأسلوب ()ToUpper في بيئة تطوير Windows Forms؟
ما هو الغرض من الأسلوب ()ToUpper في بيئة تطوير Windows Forms؟
ما هو الغرض من الأسلوب ()Clear في بيئة تطوير Windows Forms؟
ما هو الغرض من الأسلوب ()Clear في بيئة تطوير Windows Forms؟
كيف تقوم بتغيير حجم خط النص في مربع نص (TextBox) إلى 14 في بيئة تطوير Windows Forms؟
كيف تقوم بتغيير حجم خط النص في مربع نص (TextBox) إلى 14 في بيئة تطوير Windows Forms؟
باستخدام اي من الخصائص التالية يتم تحديد محاذاة النص داخل مربع النص TextBox؟
باستخدام اي من الخصائص التالية يتم تحديد محاذاة النص داخل مربع النص TextBox؟
لجعل النص في مربع النص يظهر بالخط Times New Roman وحجم الخط 16, ما هو الكود المطلوب؟
لجعل النص في مربع النص يظهر بالخط Times New Roman وحجم الخط 16, ما هو الكود المطلوب؟
ما هي الخاصية المستخدمة لإضافة صورة كخلفية لزر الامر (Button)؟
ما هي الخاصية المستخدمة لإضافة صورة كخلفية لزر الامر (Button)؟
عند برمجة تطبيق ويندوز، ما وظيفة الدالة ()Application.Exit؟
عند برمجة تطبيق ويندوز، ما وظيفة الدالة ()Application.Exit؟
Flashcards
جملة if الشرطية
جملة if الشرطية
أداة لاختبار تحقق شرط معين لتنفيذ أمر أو أوامر.
جملة if...else
جملة if...else
تستخدم لتحديد أمر أو أوامر للتنفيذ في حالة صحة المقارنة, وأوامر أخرى في حالة عدم صحتها.
أداة Checkbox
أداة Checkbox
تستخدم لتمكين المستخدم من تنشيط أكثر من اختيار في نفس الوقت.
RadioButton الأداة
RadioButton الأداة
Signup and view all the flashcards
أداة GroupBox
أداة GroupBox
Signup and view all the flashcards
الخطوط Fonts
الخطوط Fonts
Signup and view all the flashcards
الجمل الشرطية
الجمل الشرطية
Signup and view all the flashcards
Condition
Condition
Signup and view all the flashcards
تعبير المقارنة
تعبير المقارنة
Signup and view all the flashcards
جملة switch
جملة switch
Signup and view all the flashcards
المعاملات المنطقية في جملة if
المعاملات المنطقية في جملة if
Signup and view all the flashcards
جملة else
جملة else
Signup and view all the flashcards
الجملة الشرطية المتداخلة Nested if
الجملة الشرطية المتداخلة Nested if
Signup and view all the flashcards
FormBorderStyle
FormBorderStyle
Signup and view all the flashcards
ControlBox
ControlBox
Signup and view all the flashcards
المتغير orgtext
المتغير orgtext
Signup and view all the flashcards
Study Notes
Condition Statement (الجمل الشرطية)
- This chapter discusses the conditional statements, which are one of the most important programming topics, and how to use them to control the program flow.
- It also covers tools for choosing between alternatives.
Objectives
- Explain the concept of conditional statements and their uses.
- Write an if statement correctly to test whether a specific condition is true.
- Write an if...else statement to execute specific commands if the condition is met and other commands if it is not met.
- Apply logical operators to test more than one condition in an if statement.
- Apply a nested if statement correctly.
- Distinguish between using a simple if statement and a nested if statement.
- Apply a switch statement to test for the presence of a specific value.
- Use the radio button tool to display options for the user to select only one.
- Test which button is activated from a group of buttons.
- Use the checkbox tool to display options for the user to choose what they want from them.
- Test the state of the checkbox (active or inactive).
- Use the button group tool to use option buttons for more than one topic.
- Use the font class to change font properties using code.
Conditional Statement
- Conditional statements compare two values.
- The value can be a variable with another value, or a property with another.
- The conditional statement results in a (true) value if the comparison is correct, and (false) if the comparison is incorrect.
Example
- If you designed an application to enter a student's grade in a test, and the passing grade in the test is (60) or more, and less than that is failing, if you want to determine whether the student is successful or failing, you must use a conditional statement that uses a comparison expression to test the grade, which we assume is stored in the variable Score.
- Here, to determine whether the grade is greater than 60 or not, the formula is as follows: Score > 60
Examples of the results
- If Score = 75, then the value of the previous comparison is True.
- If Score = 59, then the value of the previous comparison is False.
- In conditional statements, a command or commands are determined to be executed if the comparison is true, meaning it produces (True), and also a command or other commands are executed if the relationship is incorrect, meaning it produces (False).
The "if" Conditional Statement
- This statement is used to test whether a specific condition (relationship) is true.
- An order or set of orders is implemented if the condition is true.
General form of the statement
if (Condition)
{
Statements
}
Definition of terms
- Condition: It is the condition that is tested.
- As we mentioned, this condition is a comparison expression that results in either True or False.
- The condition must be placed between ( ).
- Statements: It is the command or set of commands that are executed if the condition is met, and these commands are placed between { }.
The Conditional "if...else" Statement
- In the previous example, it is noted that when the value of the Score variable is greater than 60, a message appears to the user informing him of his success, but what if it is less? We did not tell him anything.
- Therefore, you will find that there are situations in which we have two alternatives.
- We want to implement one of them if the condition (True) is met, and implement the other alternative if the condition (False) is not met.
General form of if...else Statement
if (Condition)
{
Statement Block 1
}
else
{
Statement Block 2
}
- Condition: The condition to be tested.
- Statement Block 1: The order or orders to be implemented when the condition is met.
- Statement Block 2: The order or orders to be implemented when the condition is not met.
Using Logical Operators in a Sentence
- The logical operators can be used with an IF statement to create compound conditions.
- That is, the decision will be made based on the verification of two conditions, not just one condition.
- In such cases, it is called a compound condition because it consists of two or more conditions.
Nested Conditional Sentence "Nested if"
- Sometimes you don't have only two alternatives (condition met or not met), but there are several alternatives, and each alternative has a set of commands that need to be executed.
- In a program to calculate student grades and the grade of each student, there are multiple possibilities to calculate the grade based on the student's grade.
- The option could be failing, acceptable, good, very good, or excellent.
- This requires a new form of If that has multiple condition options
General form
if (Condition 1)
{
Statements that are executed when the first condition is met
}
else if (Condition 2)
{
Statements that are executed when the first condition is not met, and the second condition is met
}
else if (Condition 3)
{
Statements that are executed when the first and second conditions are not met, and the third condition is met
}
else
{
Statements that are executed when none of the previous conditions are met
}
Notes
- The word Else If is repeated whenever there is a need to use a new condition until all the required conditions are finished, regardless of their number.
- Each Else If is followed by several sentences that are executed when the condition is met.
- The first condition is tested, and if it is met, the set of commands that follow it are executed, and then it exits the entire if statement to complete the rest of the program.
- If the condition is not met, the next condition is tested, and if it is met, its commands are executed, and it exits from the if statement, and so on.
- All conditions are tested until one of them is met, and if one of them is met, the rest of the conditions are not tested, but if no condition is met, the commands that follow the word else will be executed if it is used (where the position of else can be ignored).
Switch statement
- When there are many possibilities that are expected to occur, or data that is likely to be entered, using an if statement becomes cumbersome to deal with therefore, if you expect at the evaluation of a certain condition many possibilities, switch statements are best.
General structure
switch (Condition)
{
case Test value 1:
Set of statements executed when the first possibility takes place
break;
case Test vaue 2:
Set of statements executed when the second possibility takes place
break;
default:
Set of statements executed if NO possibility takes places
break;
}
Text description
- Condition is the name of the element that will be tested and can be a variable or a class object, and it is written after the switch word between the ( ).
- Test_value 1 is the first possibility for the value of the variable or expression, where the value follows the word case, and similarly Test_value 2 is the second possibility ....... etc.
- You can test for the presence of several values, so the word case will be repeated several times depending on the number of values that need to be verified.
- Each case is followed by a command or group of commands that are executed when the presence of the value is verified, provided that the last line contains the word break, which aims to exit the switch statement to execute the rest of the program's commands after { that belongs to it.
- If the value in the first case is not met, it moves to the next case, then the third, and so on until the value is found; then the commands that follow it will be executed. - After executing the commands for the case that was met, the program continues after { .
- The use of the word default is optional, where it is followed by a command or group of commands that are executed if no case of the cases is met.
- If it is not written, if no value is found, none of the commands for the switch statement will be executed and the program will continue after {
Alternative Selection Tools
- Often you want to display several alternatives to the user so that he chooses one of them.
- For example, you display an option for him to activate or not activate, or you display several options for him to choose only one or more than one.
C#.NET provides 3 tools that are used to display several alternatives or options for the user to choose what suits his decision, namely
- RadioButton Tool
- This tool is used to display several alternatives (options) so that the user selects only one alternative from them.
- Like any tool, click on it from the toolbox, then place it on the form.
- The following table shows the basic properties of the tool.
Properties of RadialButtons
Name: To specify a name for the tool, usually beginning with "rad”. Appearance: For the appearance , where there are two choices, Normal or Button. Checked: Its value is True if the checkbox (button?) is active or its value is False if it is inactive.
GroupBox Tool
- The GroupBox tool is used in the model for two purposes:
- First: To organize the placement of the tools on the form.
- By showing each group of buttons for a certain topic inside a rectangle, and then you can move these tools together by moving this rectangle.
- Second: The tool is used if you have several RadioButtons on the model and you want to make each group of tools independent on its own. For instance, if you have a group button for the font color, and another group for the font size , if you place all the buttons then it is considered as a group button with connected importance, rather than each one being independent.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.