Podcast
Questions and Answers
ما هو الغرض الرئيسي للتعبيرات في البرمجة؟
ما هو الغرض الرئيسي للتعبيرات في البرمجة؟
- تعريف شكل واجهة المستخدم الرسومية.
- التحكم في تدفق البرنامج.
- تحديد أنواع البيانات المستخدمة في البرنامج.
- إجراء عملية حسابية أو مقارنة بين قيمتين. (correct)
أي من الآتية ليس نوعًا من أنواع التعبيرات في لغة #C؟
أي من الآتية ليس نوعًا من أنواع التعبيرات في لغة #C؟
- تعبيرات حسابية.
- تعبيرات إعلانية. (correct)
- تعبيرات ربط.
- تعبيرات منطقية.
أي معامل يُستخدم للحصول على باقي القسمة في العمليات الحسابية؟
أي معامل يُستخدم للحصول على باقي القسمة في العمليات الحسابية؟
- % (correct)
- +
- *
- /
ما وظيفة الدالة Math.Pow(x, y)
؟
ما وظيفة الدالة Math.Pow(x, y)
؟
إذا كانت قيمة المتغير x
هي 5، فما هي قيمة x
بعد تنفيذ العبارة ++x
؟
إذا كانت قيمة المتغير x
هي 5، فما هي قيمة x
بعد تنفيذ العبارة ++x
؟
في أي الحالات يتم استخدام تعبيرات المقارنة؟
في أي الحالات يتم استخدام تعبيرات المقارنة؟
أي من المعاملات التالية يُستخدم للتحقق من أن قيمتين متساويتين؟
أي من المعاملات التالية يُستخدم للتحقق من أن قيمتين متساويتين؟
إذا كانت قيمة A
هي 5 وقيمة B
هي 3، فما هي نتيجة التعبيرA > B
؟
إذا كانت قيمة A
هي 5 وقيمة B
هي 3، فما هي نتيجة التعبيرA > B
؟
ما هو الغرض من استخدام التعبيرات المنطقية؟
ما هو الغرض من استخدام التعبيرات المنطقية؟
أي من المعاملات المنطقية التالية يعطي قيمة True
فقط إذا كان كلا التعبيرين صحيحين؟
أي من المعاملات المنطقية التالية يعطي قيمة True
فقط إذا كان كلا التعبيرين صحيحين؟
إذا كانت قيمة A > 5
هي True
وقيمة B < 10
هي False
، فما هي قيمة التعبير (A > 5) && (B < 10)
؟
إذا كانت قيمة A > 5
هي True
وقيمة B < 10
هي False
، فما هي قيمة التعبير (A > 5) && (B < 10)
؟
ما هو المعامل الذي يُستخدم لعكس نتيجة تعبير منطقي؟
ما هو المعامل الذي يُستخدم لعكس نتيجة تعبير منطقي؟
ما هو الغرض من استخدام تعبيرات الضم (Concatenation)؟
ما هو الغرض من استخدام تعبيرات الضم (Concatenation)؟
إذا كانت قيمة المتغير firstName
هي "أحمد" وقيمة المتغير lastName
هي "محمد"، فما هي قيمة المتغير fullName
بعد تنفيذ الأمر fullName = firstName + lastName
؟
إذا كانت قيمة المتغير firstName
هي "أحمد" وقيمة المتغير lastName
هي "محمد"، فما هي قيمة المتغير fullName
بعد تنفيذ الأمر fullName = firstName + lastName
؟
ما هي معاملات التخصيص المختصرة؟
ما هي معاملات التخصيص المختصرة؟
إذا كانت قيمة x
هي 10، فما هي قيمة x
بعد تنفيذ الأمرx -= 2
؟
إذا كانت قيمة x
هي 10، فما هي قيمة x
بعد تنفيذ الأمرx -= 2
؟
ما هو الترتيب الصحيح لأولوية تنفيذ المعاملات الحسابية؟
ما هو الترتيب الصحيح لأولوية تنفيذ المعاملات الحسابية؟
ماذا يحدث عند وضع جزء من التعبير بين أقواس؟
ماذا يحدث عند وضع جزء من التعبير بين أقواس؟
ما هو الملف التنفيذي (Executable File)؟
ما هو الملف التنفيذي (Executable File)؟
أين يتم تخزين الملف التنفيذي للمشروع في العادة؟
أين يتم تخزين الملف التنفيذي للمشروع في العادة؟
ما هي فائدة استخدام الدالة Double.Parse()
لتحويل محتويات مربع نص TextBox إلى قيمة رقمية؟
ما هي فائدة استخدام الدالة Double.Parse()
لتحويل محتويات مربع نص TextBox إلى قيمة رقمية؟
ماذا يحدث إذا قمت بتوزيع الملف التنفيذي EXE فقط دون الملفات الأخرى؟
ماذا يحدث إذا قمت بتوزيع الملف التنفيذي EXE فقط دون الملفات الأخرى؟
أي العمليات التالية تعبر عن زيادة قيمة x بمقدار 1
أي العمليات التالية تعبر عن زيادة قيمة x بمقدار 1
أي من العمليات الحسابية التالية تقوم بحساب قوة العدد؟
أي من العمليات الحسابية التالية تقوم بحساب قوة العدد؟
أي من العمليات التالية تعبر عن باقي القسمة?
أي من العمليات التالية تعبر عن باقي القسمة?
أي من العبارات التالية تستخدم للمقارنة بين قيمتين?
أي من العبارات التالية تستخدم للمقارنة بين قيمتين?
أي من المعاملات التالية يستخدم للتحقق من المساواة
أي من المعاملات التالية يستخدم للتحقق من المساواة
ما هو المعامل الذي يستخدم للعكس
ما هو المعامل الذي يستخدم للعكس
ما هو المعامل الذي يعني AND
ما هو المعامل الذي يعني AND
المعامل الذي يعني XOR
المعامل الذي يعني XOR
ما هو هدف تجميع النواع حرفية معا؟
ما هو هدف تجميع النواع حرفية معا؟
X +=y في الأساس هي اختصار إلى?
X +=y في الأساس هي اختصار إلى?
ما هو الترتيب الصحيح لتنفيذ هذه العملية 2 + 3 * 4
ما هو الترتيب الصحيح لتنفيذ هذه العملية 2 + 3 * 4
ما هو الملف التنفيذي للمشروع?
ما هو الملف التنفيذي للمشروع?
اذا لم تحدد مسار حفظ المشروع اين سيتم حفظه؟
اذا لم تحدد مسار حفظ المشروع اين سيتم حفظه؟
في أي مجلد يقوم برنامج Visual Studio بتخزين الملفات التنفيذية ( *.exe ) بعد تجميع البرنامج؟
في أي مجلد يقوم برنامج Visual Studio بتخزين الملفات التنفيذية ( *.exe ) بعد تجميع البرنامج؟
Flashcards
التعبير (Expression)
التعبير (Expression)
صيغة أو معادلة ينتج عنها ناتج معين، سواء قيمة رقمية، نصية، أو منطقية.
العوامل (Operands)
العوامل (Operands)
العناصر التي سيتم تنفيذ التعبير عليها.
المعاملات (Operators)
المعاملات (Operators)
رموز تربط بين العوامل وتحدد نوع العملية.
التعبيرات الحسابية
التعبيرات الحسابية
Signup and view all the flashcards
باقي القسمة (%)
باقي القسمة (%)
Signup and view all the flashcards
الأس (Pow)
الأس (Pow)
Signup and view all the flashcards
زيادة القيمة بمقدار 1 (++)
زيادة القيمة بمقدار 1 (++)
Signup and view all the flashcards
تعبيرات المقارنة
تعبيرات المقارنة
Signup and view all the flashcards
يساوي (Equals)
يساوي (Equals)
Signup and view all the flashcards
لا يساوي (Not Equal)
لا يساوي (Not Equal)
Signup and view all the flashcards
التعبيرات المنطقية
التعبيرات المنطقية
Signup and view all the flashcards
AND (&&)
AND (&&)
Signup and view all the flashcards
OR (||)
OR (||)
Signup and view all the flashcards
NOT (!)
NOT (!)
Signup and view all the flashcards
تعبير الضم
تعبير الضم
Signup and view all the flashcards
معامل الضم (+)
معامل الضم (+)
Signup and view all the flashcards
معاملات التخصيص المختصرة
معاملات التخصيص المختصرة
Signup and view all the flashcards
x += 2
x += 2
Signup and view all the flashcards
أولوية تنفيذ المعاملات
أولوية تنفيذ المعاملات
Signup and view all the flashcards
الملف التنفيذي (Executable File)
الملف التنفيذي (Executable File)
Signup and view all the flashcards
Study Notes
- The notes below summarize the text from the images
Expressions
- Expressions can perform a calculation or compare two values
- This lecture covers how to formulate and use expressions
Lecture Objectives:
- Summarize the meaning and uses of expressions
- List the different types of expressions
- Create expressions using arithmetic operators
- Create expressions using comparison operators
- Create expressions using logical operators
- Differentiate between the operation of the AND operator and the OR operator to obtain a True result
- Link texts using the concatenation operator
- Interpret the meaning of abbreviated assignment operators
- Calculate the value of expressions according to the precedence of executing operators
- Explain the meaning of the executable file and where it is stored
What are Expressions?
- An expression is a formula or equation that produces a specific output
- The output can be a numerical, textual, or Boolean value
- Example: (7 + 2) is an expression that results in the value 9
- Example: A + B, or Textbox1 + Textbox2
- An expression consists of elements on which the expression will be executed
- These elements are called Operands
- Example: In the expression (3 - 5), the numbers 3 and 5 are operands
- Operands can be a value, like 2 + 3, or variables, like Textboxl + Textbox2
- Operators are symbols that link the operands; they determine the type of operation
- Example: The + operator means the required operation is addition
- Expressions in C#.NET can be divided into the following types based on the type of operator:
- Arithmetic expressions
- Comparison expressions
- Logical expressions
- Concatenation expressions
Arithmetic Expressions
- Arithmetic operations are essential in daily life, and C#.NET provides the following operators to perform the required arithmetic operations
- Operators are:
- Addition (+)
- Subtraction (-)
- Multiplication (*)
- Division (/)
- Remainder (%)
- Increment by 1 (++)
- Decrement by 1 (--)
- Power (Pow)
Modulo Operator
- The modulo operator (%) is used to divide two numbers, and the result of the division is the remainder of the division only
- If there is no remainder, it will produce (0)
- Example: 14 % 5 = 4, as 14 / 5 is 2 remainder 4
Power
- The Math.Pow() function is used to raise a specific number (the number before the operator) to a certain value (that follows the operator)
- Example: Math.Pow(2,3) = 8
Increasing the Value by 1
- If you have a variable X and its value is 6, and you want to increase its value by (1), use: X = X + 1
- Instead, the operator (++) can be used to increase the value of the variable by 1; the operator can be placed before or after the variable(x)
- If the operator is used as a stand-alone calculation expression, the increment will occur
- Examples:
- int x = 6
- ++X;
- int x = 6;
- X++;
- In both prior examples, the value of the variable will become (7)
- If used in another expression after executing the second statement, it will use its new value, which is (7)
Increment Operator Example
- A more complex demonstration
- Place a textbox on a Form
- Place a button on the Form
- In the button click event, put the following code:
- int a = 6, b = 9
- textBox1.Text = (a + ++b).ToString()
- When running the program, the value of the textbox will be 16
- The variable is incremented by (1) before the operation occurs
- If the variable (b) is used in any later operations, its current value of 7 is used
- If the code is modified to place the increment after the variable, such as textBox1.Text = (a + b++).ToString(), the value of the textbox will be 15 instead
Decreasing Variable Value
- Use (--) which works similarly to (+) except it decrements instead of increments
- The (--) can be placed before or after the variable with similar results
Comparison Expressions
- These expressions are used to compare two values to determine if they are equal, or if one is greater than the other
- It can be a comparison between values, variables, or control values
- A comparison results in either True or False
- Comparison Operators
- Equals (= =)
- Not Equal (!=)
- Greater than (>)
- Less than (<)
- Greater than or Equal (>=)
- Less than or Equal (<=)
- Example: if variable A = 4 and B = 3.2, the comparison outputs would be as follows:
- A > B = True
- B >= A = False
- A != B = True
- Comparison expressions are often used in IF statement conditional statements
- Based on the comparison result, a calculation can be performed, or the program's path can be directed to execute specific steps
- Different steps can be taken if the comparison result is False
Logical Expressions
- Expressions that combine multiple comparison expressions
- Linking is done via logical operators, and can be considered a compound comparison
- An example application is giving someone a raise based on two criteria (sales exceeding 10,000 and a job ranking of "second"), as this requires two comparison expressions linked with a logical operator
- If you have the two expressions A > 75 and B < 85, the two must be linked with a logical operator to generate a True or False for the whole expression
- Logical Expressions can use AND, OR, and NOT
- Logical Operators
- AND (&&): The result must be True, where both expressions return True to trigger a True result. If either expression is False, then the Logical expression will produce a False output
- OR (||): The result will be True if either or both expressions are True.
- The result will only be False only if both are False
- NOT (!): Reverses the logical expression result, such as NOT (True) = False
- The logical operator is to the left of a comparison and to the right of the other, so when calculating, the two expressions are evaluated first, then the output of the two expressions with the logical operator at the next stage
- Logical Expressions can be understood to execute in two steps
- Getting the result of the comparison expressions
- Calculate the final value of the logical expression
AND Operator Table
- True && True = True
- True && False = False
- False && True = False
- False && False = False
OR Operator Table
- True || True = True
- True || False = True
- False || True = True
- False || False = False
Example
- Given variables: A = 100, B = 40, C = 70
- The following are examples of their outputs:
- A > 100 && C > 60 = False
- A < 200 && B < 50 = True
- A > 500 && C > 70 = False
- Using the OR equivalents result in the following:
- A > 100 || C > 60 = True
- A < 200 || B < 50 = True
- A > 500 || C > 70 = False
Concatenation Expressions
- The concatenation operator is (+) and is used to merge literal values together, i.e., combine them so that they appear as one part
- If you have two variables with the following values: FirstName = “Omar” and LastName = “Essam”, the following command merges the two values to produce “OmarEssam” in the variable FullName:
- FullName = FirstName + LastName
- Note that the two words have been pasted together completely
- To add a space between them, type them as follows, adding quotation marks with a space between them:
- FullName = FirstName + " " + LastName
Abbreviated Assignment Operators
- The assignment operator (=) is used to store values or expression results inside a variable
- The value of a variable can be changed by doing an operation, such as multiplication by a number or collection on a number
- The following are common abbreviated operations with examples where x is 8:
- "Increase x by 2" is "x += 2" which uses "x = x + 2", x is equal to 10
- "Decrease x by 2" is "x -= 2" which uses "x = x - 2", x is equal to 6
- "The value of x becomes its value multiplied by 2" is "x *= 2" which uses "x = x * 2", x is equal to 16
- "The value of x becomes its value divided by 2" is "x /= 2" which uses "x = x / 2", x is equal to 4
Operator Precedence
- In general, when calculating the value of an expression, the operations are performed from left to right in the same order as the list of operations, but some operations have precedence in execution even if they appear later than another operation
Common Arithmetic Operator Precedence:
- Parentheses
- Powers
- Multiplication and Division
- Modulo (Remainder)
- Addition and Subtraction
- It is important to consider operator precedence when creating expressions
- For example: 3 + 2 * 3 = 9, while (3+2) * 3 = 15
Logical Operators Precedence
- Execution is also done according to the order from left to right, but the And (&) operator has the priority of execution over the Or (||) operator, even if it appears later in the order
Practical Exercise
- Create a program for a simple calculator that performs the basic arithmetic operations (addition, subtraction, multiplication, and division) on two numbers
Program Design
- Need two text boxes to enter the numbers
- Need a text box to show the result
- Need 4 buttons each specific to a function of the arithmetic operators required
- Need a button to exit the program
Designing the Basic Interface
- Create a new project to display the form window, and place the required tools to the look as in the opposite form which does require adjusting the properties of the tools to appear in the following form
Example Table of Object Properties (adjust as needed):
- textBox1 is named TextBox1
- textBox2 is named TextBox2
- textBox3 is named TextBox3
- Num1 label text is Labell
- Num2 label text is Label2
- Result label text is Label3
- btnAdd with addition text is Button1
- btnSub with subtraction text is Button2
- btnMultip with multiplication text is Button3
- btnDiv to use division is Button4
- btnExit can Exit via Button5
- The 'Calc' text label uses Form1
Writing the Code
- Since the buttons are performing the required functions, the commands will be in them according to their function
- To open the programming window for any of them, double-click on it to open the "Click Event Handler" tapping processor
- To proceed with the example steps, declare variable named result in the process declared for the Form to allow usage within the entire program
Add the following commands by double-clicking the add button (named btnAdd), then add the following command inside:
- result=Double.Parse(textBox1.Text)+Double.Parse(textBox2.Text);
- textBox.Text = result.ToString();
Points to Remember
- The (Parse) action converts any contents appearing in any of those texts to that of numerical values
- The Parse Process uses a specific output with the value, variable or any aspect of it, where between these you put the requested procedure
- The "ToString" task converts the numerical element to show in the text box
- Apply all previous steps to same aspects of additional steps such as the other 3 buttons but switch the calculation to the correct equivalent such as subtraction or division
- To finish press "F5"
Project Executable File
- After programmers are done with designing and testing their programs, they convert them to what is called the Executable File before distributing the copy to the user or users and they do not distribute the original copy of the program or what is called the Source Code
The Executable File:
- Encryption of orders for the program for protection which cannot be altered or viewed for different languages
- This ensures it supports programming of older models
- If you do not specify a location to save all the projects you create, they will be stored in the My Documents folder within the Visual Studio 2010 folder
- Inside this folder you will find a folder named Projects, inside it folders each with the name of a project of the projects that you design, when you enter any project folder, you will find inside the (bin) folder, inside it another folder named (Debug) You will find in the project implementation file with the EXE extension such as in the picture above
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.