PSEB 11th Computer Science -Eng Notes 2022-23 Chapter 8

 

Chapter 8th Operators and Expressions in C


1.  The symbols which are used to perform some specific type of operation on data are called?

a.  Operands                         b. Operators                        c. Expressions                      d. Formulas

2.  Which operator acts only on one operand?

a.  Unary                               b. Binary                              c. Ternary                            d. Conditional

3.  Which of the following is not a Logical Operator?

a.  And (&&)                        b. OR (||)                              c. Equality (==)                   d. NOT (!)

4.  Which symbol is used for Ternary Operator?

a. : ?                                     b. ; ?                                     c. ? :                                    d. ? ;

5.  Which of the following cannot be considered as assignment operator?

a. =                                       b. ==                                    c. +=                                     d. %=

Que:2 Fill in the Blanks:

1.                      are the data items on which operators can perform operations.

2.  Unary operator acts on only                      operand.

3.                    arithmetic operator performs only on integer operands.

4.  When value of one type is converted into some other type, it is called             .

5.  Ternary operator is also known as                          .

Ans:       1. Operands)                                    2. One                                                3. Modulus (%)

4. Type Conversion                        5. Conditional

Que:3 Very Short Answer Type Questions

Q1: Which operator causes its operand to be increased by one? Ans: Increment (++) Operator

Q2: Which operators are used to test the relationship between two variables? Ans: Relational Operators

Q3: Write all the Arithmetic Operators used in C programming. Ans: +, -, *, /, %

Q4: Which operator returns the size of its operand, in bytes? Ans: sizeof( )

Q5: Write the name of two ways of type conversion. Ans: Implicit and Explicit

Q6: How many relational operators are present in C Language? Ans: 6 (Six)

Que:4 Short Answer Type Questions. Q1: Define Expression?

Ans: Expression is like a formula in mathematics. An expression can be any valid combination of operators and operands. A valid combination is a combination that confirms the syntax rules of the C language. Expression always returns some value after evaluation. For example: x = y * z;

Q2: What is Operand?

Ans: Operands are data items on which operators can work. These operands can be variables or constant values. For example:

a + 5 * 10

In this example, operators + and * are doing their work on variable ‘a’, constant values 5 and 10. Here, ‘a’, 5 and 10 are the operands.

Q3: What is Unary operator?

Ans: Operators that require only one operand to perform their operations are called Unary Operators. For example: ++, --, ! and ~ operators etc. The following example uses increment (++) Unary Operator:

int x = 10;

++ x;

Here, ++ increment operator is a unary operator that performs its operation at only single operand

x.  This operator will increase the value of x by one unit and make its value 11.


Q4: Define Conditional operator?

Ans: Conditional operator is also known as Ternary Operator. This operator requires three operands to perform its operation. Symbols ? : are used to represent Conditional/Ternary operator. The syntax for using this operator is as follows:

Exp1? Exp2 : Exp3;

Exp1 should be a conditional expression that always returns a true (1) or false (0) result. If the result of Exp1 is true then Exp2 will perform its function otherwise Exp3 will perform its function.

Q5: What is Type Conversion?

Ans: In C language, the value of an expression can be changed to a specific type of data type as required. When one type of value is converted to another type of value, it is called Type Conversion. In C language, this conversion can be done in two ways:

1.        Implicit Conversion

2.        Explicit Conversion

Q6: What is an operator? Write the name of different types of operators?


Ans: Operators are the symbols that are used to perform specific operations on data. For example: We use + symbol to perform addition operation, * symbol is used to multiply, > symbol is used to compare etc. In these examples, +, *, > symbols (operators) are used that represents various types of operations. All operators return a value after performing their operation. Operators can be divided into the following three types:

         Unary Operators

         Binary Operators

         Ternary Operators

 

 

 

Q7: Write about increment and decrement operators?

Ans: The increment and decrement operators are the unary operators. The ++ sign is used for the increment operator and the -- sign is used for the decrement operator. The increment operator (++) increases the value of its operand by one while the decrement operator (--) decreases the value of its operand by one. The operand used with these operators must be a variable. They cannot be applied directly to a fixed value.

for example:

int x = 10;

++ x;                            It will increase the value of x to 11.

--x;                               It will decrease the value of x (10) to 9.

Que:5 Long Answer Type Questions.

Q:1 Explain the Arithmetic Operators? Write any program using Arithmetic Operators?

Ans: Arithmetic operators are used to perform arithmetic operations, such as: addition, subtraction, multiplication, division, etc. There are 5 arithmetic operators in C language: + (addition), - (subtraction), * (multiplication), / (division), and % (modules). Following program shows the use of arithmetic operators in C language:




Q:2 What are Relational operators? Write a program for Relational operator?

Ans: Relational operators are also called Comparison Operators. These operators are used to compare values. After comparing the values, these operators return either true (1) or false (0) value. There are 6 relational operators in C language: == (Equals to), != (Not Equal to), > (Greater than),

< (Less than), >= (Greater than or equal to) and <= (Less than or equal to). All these are Binary operators. Following Program shows the use of relational operators in C:



Q:3 Explain Logical operators? Write any program of Logical operator?

Ans: Logical operators are also called Boolean Operators. These operators are used when we have to test more than one test condition at a time. There are 3 logical operators in C language: && (Logical AND), || (Logical OR) and ! (Logical NOT). ‘Logical AND’ and ‘Logical OR’ are the binary operators while ‘Logical NOT’ is a unary operator. These operators also return either true (1) or false (0) result after performing their operations. Following program shows the use of logical operators in C Language:



No comments:

Post a Comment