Class Matric Part 2 NotesComputer class 10th

10th class computer science chapter 2 User Interaction

10th class computer science chapter 2 User Interaction on newsongoogle.com by Bilal Articles

Shorts and Simple Question & Answers

Q.1:Define a computer.
Ans.
A computer is a device that takes data as input, process that data and generates the output.


Q.2: Define printf function?
Ans.
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. All data types can be displayed with printf function.


Q.3: What is format specifier?
Ans.
Format specifiers are used to specify format of data type during input and output operations. Format specifier is always preceded by a percentage (%) sign.
the format spe 4. Write down the format specifiers against different data types in C language.
Ans.Format specifiers against different data types in C language are as follows:
Data type Format Specifier
int %d or % i
float % f
char % c

Q.5: If float height= 5.8; int age = 35; What will be the output of following statement: printf(“My age is %d and my height is %. 2f”, age, height);
Ans.
Output: My age is 35 and my height is 5.80


Q.6: What will be the output of following code:

#include<stdio.h>

void main()
{ printf(“Sum of 23 and 45 is %d”, 23 + 45); }
Ans.
Output Sum of 23 and 45 is 68


Q.7: What is the purpose of scanf()?
Ans.
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. If user enters integer data type, format specifier mentioned in scanf must be %d or %i.


Q.8: What is common mistake in scanf function?
Ans.
It is a very common mistake to forget & sign in the scanf function. Without & sign, the program gets executed but does not behave as expected.


Q.9: What is the use of getch()?
Ans.
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.


Q.10: Which library function is used to include getch()?
Ans:
To use this function, we need to include the library conio.h in the header section of program.


Q. 11: What is statement terminator?
Ans.
A statement terminator is identifier for compiler which identifies end of a line. In C language semi colon (;) is used as statement terminator. If we do not end each statement with a; it results into error.


Q.12: What is the purpose of escape sequence in C language?
Ans.
Escape sequence are used in printf function inside the double quotes (” “). It force printf to change its normal behaviour of showing output.


Q.13: What is Formation of escape sequence?
Ans.
Escape sequence consists of two characters. The first character is always back slash (1) and the second character varies according to the functionality that we want to achieve. Back slash (1) is called escape character which is associated with each escape sequence to notify about escape.


Q.14: What is the purpose of \n?
Ans.
After escape character, \n specifies movement of the cursor to start of the next line. This escape sequence is used to print the output on multiple lines.


Q.15: What is the purpose of Tab (\t)?
Ans.
Escape sequence It specifies the I/O function of moving to the next tab stop horizontally. A tab stop is collection of 8 spaces. Using It takes cursor to the next tab stop. This escape sequence is used when user presents data with more spaces.


Q.16: What is an operator?
Ans.
An operator in a programming language is a symbol that tells the compiler or interpreter to perform specific mathematical, relational or logical operation and produce final result.


Q.17: Write down the name of basic operator?
Ans:
C language offers numerous operators to manipulate and process data. Following is the list of some basic operator types:
Assignment operator
Arithmetic operator
Logical operator
Relational operator


Q.18. What is assignment operator?
Ans.
Assignment operator is used to assign a value to a variable, or assign a value of variable to another variable. Equal sign (=) is used as assignment operator in C.


Q.19: Write a program that swaps the values of two integer variables.
Ans
#include<stdio.h>

#include<stdio.h>

void main()
{
clrscr();
int a = 2, b = 3, temp;
temp = a;
a = b;
b = temp;
printf(“Value of a after swapping: %d\n”, a); a after
printf(“Value of b after swapping: %d\n:, b);
getch();
}

Q.20: What is the use of an arithmetic operator?
Ans. Arithmetic Operators are used to perform arithmetic operations on data.


Q.21: What is Division operator?
Ans.
Division operator (/) divides the value of left operand by the value of right operand.
e.g. Float result = 3.0/2.0;
After the statement, the variable result contains the value 1.5.


Q.22: What is Multiplication operator?
Ans.
Multiplication operator () is a binary operator which performs the product of two numbers. e.g. int multiply = 55;
After the execution of statement, the variable multiply contains value 25.

Q.23: What is an Addition operator?
Ans.
Addition operator (+) calculates the sum of two operands.
e.g. int add = 10 + 10;
Resultant value in variable add is 20.


Q.24: Why the statement a = a + 1; and a–; are used in C language?
Ans.
The statement a = a + 1; is used to increase the value of variable a by 1. In C language, this statement can also be written as a++; or ++a; similarly, a or — a; used to decrease the value of a by 1.


Q.25: What is Subtraction operator?
Ans.
Subtraction operator (-) subtracts right operand from the left operand.
e.g. int result = 20-15;
After performing subtraction, value 5 is assigned to the variable result.


Q.26: What is Modulus operator?
Ans.
Modulus operator (%) performs divisions of left operand by
by the
right operand and returns
the remainder value after division. Modulus operator works on integer data types.
int remaining = 14% 3; As, when we divide 14 by 3, we get a remainder of 2, so the value stored in variable remaining is 2.


Q 27: What is common mistake while writing arithmetic statement is C language?
Ans.
While writing arithmetic statement is C language, a common mistake is to follow the usual algebraic rules e.g. writing 6 y as 6y, and writing xxx as x³ etc. It results in a compiler error.


Q.28: Why relational operators are used in C language?
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. C language allows us to perform relational operators on numeric and char type data.


Q.29: What is difference between Assignment operator and equal to operator?
Ans.
In C language, equal to operator is used to check for equality of two expressions, whereas assignment operator assigns the result of expression on right side to the variable on left side. Double equal operator (==) checks whether right and left operands are equal or not. Single equal operator (=) assigns right operand to the variable on left side.


Q.30: What is difference between logical operator and arithmetic operator?
Ans.

Logical operator
Logical operators perform operations on Boolean expression and produce a Boolean expression as a result. The result of a relational operation is a Boolean expression, so logical operators can be performed to evaluate more than one relational expression.
Arithmetic Operator
Arithmetic Operators are used to perform arithmetic operations on data. Division operator, multiplication operator and modulus operator is some arithmetic operator.


Q.31:What is difference between Division operator and Multiplication operator?
Ans.

Division Operator
Division operator (1) divides the value of left operand by the value of right operand.
Example: Float result – 3.0/2.0;
Multiplication Operator
Multiplication operator () is a binary operator which performs the product of two numbers. Example: int multiply = 55;


Q.32: Define logical operator?
Ans.
Logical operators perform operations on Boolean expression and produce a Boolean expression as a result. The result of a relational operation is a Boolean expression, so logical operators can be performed to evaluate more than one relational expression.

Q.33: Write down the name of logical operator.
Ans.
The logical operators are as follows:
Operator Description tion
&& Logical AND
!! Logical OR
! Logical NOT

Q.34: What is AND operator (&&)? Also write its truth table.
Ans.
AND operator && takes two Boolean expressions as operands and produces the result true if both of its operands are true. It returns false if any of the operands is false. The truth table for AND operator is shown below

Expression 1 Operator Expression 2 Operator
False && False False
False && True False
True && False False
True && True True

Q.35: What is OR operator (||)?
Ans.
OR operator accepts Boolean expression and returns true if at least one of the operands is true.
Q.36: Draw the truth table for OR operator.
Ans.The truth table for OR operator is shown below:
Expression 1 Operator Expression 2 Operator
False || False False
False || True True
True || False True
True || True True

Q.37: What is NOT operator (I)? Also draw truth table
Ans.
NOT operator negates or reverses the value of Boolean expression. It makes it true, if it is false and false if it is true. The truth table for Not operator is given below:
Expression Operat Result
True || False
False || True

Q.38: Differentiate between Unary and Binary Operators.
Ans.

Unary Operator
Unary operators are applied over one operand only e.g. logical not (!) operator has only one operand. Sign operator (-) is another example of a unary operator e.g. -5
Binary Operator
Binary Operator require two operands to perform the operation e.g. all the arithmetic operators, and relational operators are binary operators. The logical operators && and || are also binary operators.


Q.39: What is Operators’ Precedence?
Binary Operator
Ans.
If there are multiple operators in an expression, the question arises that which operator is evaluated first. To solve this issue, 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.


Q.40: Define Ternary operator?
Ans:
The operator offers three operands in C programming Language is called ternary operator.


Q.42: Differentiate between scanf and getch()?
Ans:

scanf
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. If user enters integer data type, format specifier mentioned in scanf must be %d or %i.
getch()
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. To use this function, we need to include the library conio.h in the header section of program.


Q.43: What is the difference between == operator and operator?
Ans: In C language, == operator is used to check for equality of two expressions, where as = operator assigns the result of expression on right side to the variable on left side. Double equal operator (==) checks whether right and left operands are equal or not. Single equal operator (=) assigns right operand to the variable on left side. expressio


Q.44: Write use of clrscr()?
Ans: This function is used to clear the output screen of C language editor.
Syntax: clrscr();

Multiple Choice Question

MCQS

1. A is a device that takes data as input, process that data and generates the output.
A. Computer✅

B. Printer
C. Mobile
D. All of these


2. Each programming language has its…….or functions for I/O operations.
A. Keywords
B. standard library
C. Language
D. both a and b✅


3. C language offers printf function to display the:
A. Program
B. Input
C. Output✅
D. All of these


4. function is used to get input from user.
A. getch
B. scanf✅
C. printf
D. print


5. The name of printf comes from that is used to print the formatted output on screen.
A. “escape sequence
B. “unprinted formatted”
C. “printed sequence”
D. “print formatted”✅


6. The format specifier % f show the data type
A. int
B. float✅
C. char
D. All of these


7. The format specifier % c show the data type
A. int
B. float
C. char✅
D. Grouped


8. When we use %f to display a float value, it display digits after the decimal point.
A. 5
B. 6✅
C. 7
D. 8


9. scanf is a built-in function in C language that takes from user into the variables
A. Input✅

B. Output
C. Instruction
D. Guideline


10 The expected input data type in scanf function can be specified with the help of
A. scanf
B. Escape sequence
C. format specifier✅
D. logical operator


11. The main parts ain parts of of scanf sce function
A. 2✅

B. 3
C. 4
D. 5


12. The first part of scanf function is
A. inside the single quotes
B. inside the double quotes✅
C. inside the curly bracket
D. inside the triple quotes


13. Without & sign in scanf function, the program gets but does not behave as expected.
A. Instruction
B. Complied
C. Executed✅
D. Input


14. The common mistake in scanf function sign.
A. &✅
B. %
C. *
D. $


15. function is used to read a character from user.
A. printf
B. getch()✅
C. scanf
D. scan


16. To use getch() function, there is a need to include the library in the header section of program.
A. stdio.h
B. void main()
C. conio.h✅
D. include.h


17. When we read character through scanf, it requires us to for further execution.
A. Press enter✅
B. Press esc
C. Press shift
D. Press ctrl


18. A is identifier for compiler which identifies end of a line.
A. Format specifier
B. Escape sequence
C. Statement terminator✅
D. Logical operator


19. In C language is used as statement terminator.
A. !
B. ;✅
C. %
D. ,

20. are used in printf function inside the “and”.
A. Terminator
B. Statement terminator
C. Escape terminator✅
D. Format specifier


21. printf(“My name is \”Ali\””); 21 In the above statement \” is an
A. Escape sequence✅
B. Format specifier
C. Format
D. Operator


22. consist of two characters.
A. Format specifier
B. Escape sequence✅
C. Statement terminator
D. All of these


23. What is the purpose of escape sequence \?
A. Display Back slash✅
B. Generates an alert sound
C. Removes previous char
D. Display Single Quote


24. What is the purpose of escape sequence \a?
A. Display Single Quote
B. Removes previous char
C. Generates an alert sound✅
D. Display Back slash


25. After escape character, specifies movement of the cursor to start of the next line.
A. \t
B. \n✅
C. \b
D. \a


26. Which escape sequence is used to print the output on multiple lines?
A. \a
B. \b
C. \c
D. \n✅


27. Escape sequence specifier the I/O function of moving to the next tab stop horizontally.

A. \m
B. \n
C. \t✅
D. \


28. The list of some basic operator types is
A. Assignment operator
B. Arithmetic operator
C. Relational operator
D. All of these✅


29. is used to assign a value to a variable, or assign a value of variable to another variable.
A. Arithmetic operator
B. Assignment operator✅
C. Logical operator
D. Relational operator


30. is used as assignment operator in C.
A. =✅

B. $
C. !
D. %


31. are used to perform arithmetic operations on data.
A. Arithmetic operator✅

B. Assignment operator
C. Logical operator
D. Relational operator


32. What is the name of /operator?
A. Multiplication operator
B. Subtraction operator
C. Division operator✅
D. Addition oprator


33. divides the value of left operand by the value of right operand.
A. Division operator✅

B. Multiplication operator
C. Addition operator
D. Modulus operator


34. If both the operands are of type int, then result of division is also type of
A. char
B. var
C. int✅
D. All of these


35. is a binary operator which performs the product of two numbers.
A. Logical operator
B. Arithmetic operator
C. Multiplication operator✅
D. Division operator


36. calculates the sum of two operands.
A. Arithmetic operator✅

B. Multiplication operator
C. Division operator
D. Logical operator


37. The statement a–; or –a; used to decrease the value of a by
A. 1✅

B. 1.5
C. 1.8
D. -1


38. subtracts right operand from the left operand.
A. Arithmetic operator
B. Multiplication operator
C. Division operator
D. Subtraction Operator✅


39. What is the name of % operator
A. Multiplication operator
B. Modulus operator✅
C. Division operator
D. Subtraction Operator


40. performs divisions of left operand by the right operand and returns the remainder value After division
A. Modulus operator✅

B. Division operator
C. Subtraction Operator
D. Arithmetic operator

41. compare two values to determine the relationship between values.
A. Arithmetic operator
B. Relational operator✅
C. Logical operator
D. Binary operator


42. C language allows us to perform relational operators on and data type.
A. int
B. Numeric
C. char
D. Both b and c✅


43. A true value of relational operator is represented by

A. 0
B. 1✅
C. 2
D. 3


44. A false value relational operator is represented by
A. 0✅

B. 1
C. 3
D. 2


45. In C language, operator is used to check for equality of two expressions.
A. Assignment operator✅

B. Arithmetic operator
C. Logical operator
D. Relational operator


46. operator assigns the result of expression on right side to the variable on left side.
A. ==
B. =✅
C. *
D. %


47. perform operations on Boolean expression and produce a Boolean expression as a result.
A. Logical operator✅

B. Assignment operator
C. Arithmetic operator
D. Relational operator


48. Which one from the following is not a logical operator?
A. AND
B. OR
C. NAND✅
D. NOT


49. operator takes two Boolean expressions as operands and produces the result true if both of its operands are true.
A. AND✅
B. OR
C. NAND NAND
D. NOT


50. accepts Boolean expression and returns true if at least one of the operands is true.
A. AND
B. OR✅
C. NAND
D. NOT


51. operator negates or reverses the value of Boolean expression. It makes it true, if it is false and false if it is true.
A. NOT✅

B. AND
C. OR
D. NAND


52. require two operands to perform the operation.
A. Relational operator
B. Unary operator
C. Binary Operator✅
D. Logical Operator


53. are applied over one operand only.
A. Unary operator✅

B. Binary Operator
C. Logical Operator
D. Relational operator


54. Which operator has high precedence?
A. &
B. A
C. ()✅
D. !


55. operator are applied on three operand.
A. Ternary✅

B. Unary
C. Binary
D. Logical


56. function is used to clear the output screen of C language editor.
A. getch();
B. scanf
C. printf✅
D. clrscr();

Related Articles

Back to top button
Enable Notifications OK No thanks