10th Class Computer New Course User Interaction Unit-02
Q.1 Multiple choice questions.
- printf is used to print ____________________ type of data.
d) All of them (Correct Answer)
2. scanf is a ____________________ in C programming language.
c) function (Correct Answer)
d) none of them
3. getch() is used to take ____________________ as input from user.
d) all of them (Correct Answer)
4. Let the following part of code, what will be the value of variable a after execution:
int a = 4;
float b = 2.2;
a = a*b;
b) 8 (Correct Answer)
5. Which of the following is a valid line of code.
a) int = 20;
b) grade = ‘A’; (Correct Answer)
c) line = this is a line
d) none of these
6. Which operator has highest precedence among the following:.
d) ! (Correct Answer)
7. Which of the following is not a type of operator:
a) Arithmetic operator
b) Check operator (Correct Answer)
c) Relational operator
d) Logical operator
8. The operator % is used to calculate ____________________.
b) Remainder (Correct Answer)
9. Which of the following is a valid character:
c) ‘9’ (Correct Answer)
d) none of them
10. What is true about C language:
a) C is not a case sensitive language
b) Keywords can be used as variable names
c) All logical operators are binary operators
d) none of them (Correct Answer)
Q.2 True or False
- Maximum value that can be stored by an integer is 32000.
2. Format specifiers begin with a % sign.
3. Precedence of division operator is greater than multiplication operator.
4. getch is used to take all types of data input from user.
5. Scanf is used for output operations.
Q.3 Define the following.
1) Statement Terminator
A statement terminator is identifier for compiler which identifies end of a statement. In C language semi colon(;) is used as statement terminator.
2) Format Specifier
Format specifier are used to specify format of data type during input and output operations. Format specifier is always preceded by a percentage (%) sign.
3) Escape Sequence
Escape sequence forces printf to escape from its normal behavior. It is the combination of escape character (\) and a character associated with special functionality.
scanf is a built-in function in C language that takes input from user into the variable.
5) Modulus Operator
Modulus operator is a binary operator, which performs division of left operand to the right operand and returns the remainder value after division. Modulus operator works on integer data type.
Q.4 Briefly answer the following questions.
1) What is the difference between scanf and getch?
Answer: Difference between scanf and getch
scanf is a built-in function in C language that takes input from user into the variables. We specify the expected input data type in scanf function with the help of format specifier, while getch() function is used to read a character from user. The character entered by user does not get displayed on screen. This function is generally used to hold the execution of program because the program does not continue further until the user types a key.
2) Which function of C language is used to display output on screen?
printf is a built-in function in C programming language to show output on screen. Its name comes from “print formatted” that is used to print the formatted output on screen.
3) Why format specifiers are important to be specified in I/O operations?
Answer: Importance of Format Specifiers
If we want to display the value of a variable then we use format specifiers. For example if want to show int type data, then we must specify it inside the printf by using format specifier %d or %i. In the same way, for float type data we must use %f.
Without these format specifiers we cannot get the value of the variables in printf.
4) What are escape sequences? Why do we need them?
Answer: Escape Sequence
Escape sequences are used in printf function inside the “and “. They force printf to change its normal behavior of showing output.
5) Which operators are used for arithmetic operations?
Answer: Arithmetic Operators
Divide the left side value by a right side value
Used to multiply two values
Used to add two values
Used to subtract two values
It gives the remainder value after dividing the left value by right value
6) What are relational operator? Describe with an example.
Answer: Relational Operators
== (equal to)
5 equal to 5
!= (not equal to)
5 not equal to 7
> (greater than)
5 greater than 7
< (less than)
5 less than 7
>= (greater than equal to)
5 greater than or equal to 5
<= (less than equal to)
5 less than or equal to 4
7) What are logical operators? Describe with an example.
Answer: Logical Operators
Logical operators perform operations on Boolean expressions and produce a Boolean expression as a result. Logical operations are used to evaluate more than one relational expressions.
&& (logical AND)
3 is less than 4 AND 7 is greater than 8
|| (logical OR)
3==4 || 3>1
3 is equal to 4 OR 3 is greater than 1
! (logical NOT)
!(4>2 || 2==2)
NOT (4 is greater than 2 OR 2 is equal to 2)
8) What is the difference between unary operators and binary operators?
Answer: Difference between unary and binary operators
Unary operators require one operand to perform the operation, while the binary operator require two operands to perform the operation.
9) What is the difference between == operator and = operator?
Answer: Difference between == operator and = operator
== Operator is used to check whether the value on left hand side is equal to the value at the right hand side, while = is used to assign the value (right hand side operand) to a variable (left hand side operand).
10) What is meant by precedence of operator? Which operator has the highest precedence in C language?
Answer: Operators’ Precedence
If there are multiple operators in an expression, the question arises that which operator is evaluated first. To solve this issue, a precedence has been given to each operator. An operator with higher precedence is evaluated before the operator with lower precedence. In case of equal precedence, the operator at left side is evaluated before the operator at right side.
Operator with highest precedence:
() operator has the highest precedence among all operators.
10th Class Computer Unit-05: Functions
10th Class Computer New Course Data & Repetition Unit-04
10th Computer New Course Conditional Logic Unit-03
10th Class Computer New Course ITP Unit-01
9th Computer New Course Designing Website Unit-05
9th Computer New Course Data and Privacy Unit-04
9th Computer New Course Networks Unit-03
9th Computer New Course Binary System Unit-02
9th Computer New Course Problem Solving Unit-01
Buy Best Stationery Products in Pakistan
Piano Ballpoint Pen
ORO Trimetal Pencil
Dollar Clipper Pen
UHU 10×7 ml Pack of 10 PCs
Glue Stick 8g Pack Of 12 PCs
Color Pencils Box of 12 PCs
For more stationery items please visit : https://stationerystore.pk