#### 10th Class Computer Chapter 02 – User Interactions

**Q. 1. What is printf Function?**

**Ans:** It is a built-in function in C language that is used to Show Output on the Screen. Structure of printf function is printf();

**Q. 2. Describe Format specifiere.**

**Ans: **it is used to specify the format of the data type during INPUT and OUTPUT operation. We use (%) sign before the format specifiere i.e. %d, %f etc.

**Q. 3. What is scanf Funtion?**

**Ans:** It is a built-in function in C language that is used to take INPUT from the users into variables. Structure of *scanf *function is scanf();

**Q. 4. Describe Statement Terminator.**

**Ans: **It is an identifier for compiler which identifies end of the statement. In C language *semi colon (;) *is used as statement terminator.

**Q. 5. Explain Escape Sequence?**

**Ans:** It is Used to change the normal behavior of the output. It is combination of escape character (\) and character associated with special functionality. i.e. Escape Sequence \n specifies to move the cursor to the new/next line. Escape Sequence \t is used to move the cursor to the next tab means 8 spaces.

Example:

Printf(“I am a \n good Student”);

Output: I am a

good Student

Printf(“I am a \t good student”) output: I am a good student

**Q. 6. Explain Different Types of Operators?**

**Ans: **C language offers different operators to manipulate and process data. Following are some basic operators:

- Assignment Operator
- Arithmetic Operator
- Logical Operator
- Relational Operator

**Q. 7. What is Assignment Operators?**

**Ans: **Assignment operator is used to assign a value to variables, or assign a value of variable to another variable. *Equal *(=) is used as assignment operator in C. for example

int sum=5;

int a=sum;

So value 5 is assigned to variable 5 in first example. Value of variable ** sum** is assigned to variable an example 2.

**Q. 7. What is Arithmetic Operators?**

**Ans: **Arithmetic operators are used to perform arithmetic (Mathematical) operations on data. i.e. Division, Multiplication, Addition, Subtraction and Modulus Operator.

**Division Operator: **Division Operator (/) divides the value of left operand by the value of right operand. E.g. 6/2=3 or int c=50/10

**Multiplication Operator: **Multiplication operator (*) is binary operator which performs the product of two numbers, e.g. 6*7=42 or int area=length*width

**Addition Operator: **Addition operator(+) calculates the sum of two operands, e.g. int add=15+23

**Subtraction Operator: **Subtraction Operator (-) subtracts the right operand from the left operand, e.g. int result =25-10 After performing subtraction, value 15 is assigned to the variable result.

**Modulus Operator: **Modulus operator (%) performs division of left operand by the right operand and returns the remainder of value after division, e.g.\

int remaining = 14%3

So when we divide 14 by 3, we get a remainder of 2, so the value stored in variable remaining is 2.

**Q.8.What are Relational Operators?**

**Ans: **Relational Operators compare two values to determine the relationship between values. Relational operators identify either the values are equal, not equal, greater than or less than one another.

Relational Operator | Description |

== | Equal to |

!= | Not Equal to |

> | Greater Than |

< | Less Than |

>= | Greater Than Equal to |

<= | Less Than Equal to |

For Example:

Relational Operator | Description |

7==7 | 7 is Equal to 7. |

12 != 23 | 12 is Not Equal to 23. |

6 > 3 | 6 is Greater Than 3. |

23 < 45 | 23 is Less Than 45. |

5 >= 5 | 5 is Greater Than Equal to 5. |

7 <= 90 | 7 is Less Than Equal to 90. |

**Q. 9. What are Logical Operators?**

**Ans: **Logical operators are used for Boolean expressions and produce a Boolean expressions as a result.

Logical Operator | Description |

&& | Logical AND |

|| | Logical OR |

! | Logical NOT |

**Logical AND Operator: **AND operator (&&) takes two or more operands and produce result *true *if all the operands are true. It returns *false *if any operand is *false.*

**Logical OR Operator: **OR operator (||) takes two or more operands and produce result *true *if any operand is true. It returns *false *when all the operands are *false.*

**Logical NOT Operator: **NOT operator (!) negates or reverse the value of Boolean expression. It makes it *true *if it is *false. *And makes it *false *if it is *true.*

**Q.11. Difference between Unary and Binary Operator?**

**Ans: **Operators are divided into two categories on the basis of number of operands.

**Unary Operator:**Unary operators are applied on one operand only e.g. logical NOT (!) operator, sign operator. For example, +5, -11, !a etc;**Binary Operator:**Binary Operator requires two operands to perform operation e.g. all the arithmetic and relational operators are binary operators. For Example 3+9, 8<21 etc;

**Q. 12. What is Operators’ Precedence?**

**Ans: **All the operators have been given precedence, an operator with higher precedence is evaluated before the operator with lower precedence. In case of equal precedence left side operator is evaluated before the right side operator.

Operator | ( ) | ! | *, /, % | +, – | >, <, >=, <= | ==, != | && | || | = |

Precedence | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |

## Post Comment