ما هي التعابير؟

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

ما هو الغرض الرئيسي للتعبيرات في البرمجة؟

  • تعريف شكل واجهة المستخدم الرسومية.
  • التحكم في تدفق البرنامج.
  • تحديد أنواع البيانات المستخدمة في البرنامج.
  • إجراء عملية حسابية أو مقارنة بين قيمتين. (correct)

أي من الآتية ليس نوعًا من أنواع التعبيرات في لغة #C؟

  • تعبيرات حسابية.
  • تعبيرات إعلانية. (correct)
  • تعبيرات ربط.
  • تعبيرات منطقية.

أي معامل يُستخدم للحصول على باقي القسمة في العمليات الحسابية؟

  • % (correct)
  • +
  • *
  • /

ما وظيفة الدالة Math.Pow(x, y)؟

<p>رفع العدد x إلى القوة y. (B)</p> Signup and view all the answers

إذا كانت قيمة المتغير x هي 5، فما هي قيمة x بعد تنفيذ العبارة ++x؟

<p>6 (D)</p> Signup and view all the answers

في أي الحالات يتم استخدام تعبيرات المقارنة؟

<p>لتحديد العلاقة بين قيمتين. (B)</p> Signup and view all the answers

أي من المعاملات التالية يُستخدم للتحقق من أن قيمتين متساويتين؟

<p>== (B)</p> Signup and view all the answers

إذا كانت قيمة A هي 5 وقيمة B هي 3، فما هي نتيجة التعبيرA > B؟

<p>True (D)</p> Signup and view all the answers

ما هو الغرض من استخدام التعبيرات المنطقية؟

<p>للربط بين تعبيرات مقارنة. (B)</p> Signup and view all the answers

أي من المعاملات المنطقية التالية يعطي قيمة True فقط إذا كان كلا التعبيرين صحيحين؟

<p>AND (B)</p> Signup and view all the answers

إذا كانت قيمة A > 5 هي True وقيمة B < 10 هي False، فما هي قيمة التعبير (A > 5) && (B < 10)؟

<p>False (C)</p> Signup and view all the answers

ما هو المعامل الذي يُستخدم لعكس نتيجة تعبير منطقي؟

<p>NOT (A)</p> Signup and view all the answers

ما هو الغرض من استخدام تعبيرات الضم (Concatenation)؟

<p>دمج قيمتين حرفيتين معًا. (B)</p> Signup and view all the answers

إذا كانت قيمة المتغير firstName هي "أحمد" وقيمة المتغير lastName هي "محمد"، فما هي قيمة المتغير fullName بعد تنفيذ الأمر fullName = firstName + lastName؟

<p>أحمد محمد (B)</p> Signup and view all the answers

ما هي معاملات التخصيص المختصرة؟

<p>اختصارات لتعديل قيمة المتغير. (C)</p> Signup and view all the answers

إذا كانت قيمة x هي 10، فما هي قيمة x بعد تنفيذ الأمرx -= 2؟

<p>8 (C)</p> Signup and view all the answers

ما هو الترتيب الصحيح لأولوية تنفيذ المعاملات الحسابية؟

<p>الأقواس، الأسس، الضرب والقسمة، الجمع والطرح (D)</p> Signup and view all the answers

ماذا يحدث عند وضع جزء من التعبير بين أقواس؟

<p>يتم تنفيذه أولاً بغض النظر عن أولويته. (D)</p> Signup and view all the answers

ما هو الملف التنفيذي (Executable File)؟

<p>ملف مشفر يحتوي على أوامر البرنامج. (A)</p> Signup and view all the answers

أين يتم تخزين الملف التنفيذي للمشروع في العادة؟

<p>في مجلد فرعي باسم 'bin' ثم 'Debug'. (C)</p> Signup and view all the answers

ما هي فائدة استخدام الدالة Double.Parse() لتحويل محتويات مربع نص TextBox إلى قيمة رقمية؟

<p>لإجراء عمليات حسابية عليه. (C)</p> Signup and view all the answers

ماذا يحدث إذا قمت بتوزيع الملف التنفيذي EXE فقط دون الملفات الأخرى؟

<p>قد لا يعمل البرنامج بشكل صحيح. (A)</p> Signup and view all the answers

أي العمليات التالية تعبر عن زيادة قيمة x بمقدار 1

<p>كل ما سبق (C)</p> Signup and view all the answers

أي من العمليات الحسابية التالية تقوم بحساب قوة العدد؟

<p>Math.power(x,y) (B)</p> Signup and view all the answers

أي من العمليات التالية تعبر عن باقي القسمة?

<p>x % y (B)</p> Signup and view all the answers

أي من العبارات التالية تستخدم للمقارنة بين قيمتين?

<p>x &gt; y (C)</p> Signup and view all the answers

أي من المعاملات التالية يستخدم للتحقق من المساواة

<p>== (E)</p> Signup and view all the answers

ما هو المعامل الذي يستخدم للعكس

<p>! (B)</p> Signup and view all the answers

ما هو المعامل الذي يعني AND

<p>&amp;&amp; (A)</p> Signup and view all the answers

المعامل الذي يعني XOR

<p>^ (C)</p> Signup and view all the answers

ما هو هدف تجميع النواع حرفية معا؟

<p>تكوين سلسلة نصية واحدة (A)</p> Signup and view all the answers

X +=y في الأساس هي اختصار إلى?

<p>x = x + y (A)</p> Signup and view all the answers

ما هو الترتيب الصحيح لتنفيذ هذه العملية 2 + 3 * 4

<p>يتم تنفيذ الضرب ثم الجمع (D)</p> Signup and view all the answers

ما هو الملف التنفيذي للمشروع?

<p>ملف مشفر (B)</p> Signup and view all the answers

اذا لم تحدد مسار حفظ المشروع اين سيتم حفظه؟

<p>My documents (C)</p> Signup and view all the answers

في أي مجلد يقوم برنامج Visual Studio بتخزين الملفات التنفيذية ( ‎*.exe ) بعد تجميع البرنامج؟

<p>اسم_المشروع/bin/Debug (C)</p> Signup and view all the answers

Flashcards

التعبير (Expression)

صيغة أو معادلة ينتج عنها ناتج معين، سواء قيمة رقمية، نصية، أو منطقية.

العوامل (Operands)

العناصر التي سيتم تنفيذ التعبير عليها.

المعاملات (Operators)

رموز تربط بين العوامل وتحدد نوع العملية.

التعبيرات الحسابية

تعبيرات تستخدم لإجراء عمليات حسابية.

Signup and view all the flashcards

باقي القسمة (%)

إيجاد الجزء المتبقي من القسمة.

Signup and view all the flashcards

الأس (Pow)

رفع عدد لقوة معينة.

Signup and view all the flashcards

زيادة القيمة بمقدار 1 (++)

زيادة قيمة المتغير بمقدار 1.

Signup and view all the flashcards

تعبيرات المقارنة

مقارنة بين قيمتين.

Signup and view all the flashcards

يساوي (Equals)

تحديد هل القيمتين متساويتين.

Signup and view all the flashcards

لا يساوي (Not Equal)

تحديد هل القيمتين مختلفتين.

Signup and view all the flashcards

التعبيرات المنطقية

تعبيرات تربط بين تعبيرات مقارنة باستخدام معاملات منطقية.

Signup and view all the flashcards

AND (&&)

يجب أن يكون ناتج التعبيرين True لتكون النتيجة النهائية True.

Signup and view all the flashcards

OR (||)

تكون النتيجة True إذا كان أحد التعبيرين True.

Signup and view all the flashcards

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)

تشفير لأوامر البرنامج لحماية الكود.

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.

Quiz Team

Related Documents

More Like This

Order of Operations Quiz
5 questions
Understanding Algebraic Expressions
10 questions
Math Operations and Expressions Quiz
5 questions
Matematické výrazy a operátory
13 questions
Use Quizgecko on...
Browser
Browser