Class 10 Computer Science Unit 2 – User Interaction Notes – MCQs, Short & Long Questions

Class 10 Computer Science Unit 2 – User Interaction focuses on how a program communicates with the user. In this unit, students learn how to take input from the user, display output, and perform operations using operators. These concepts are essential for creating interactive programs that can respond to user inputs and process data effectively.

This post includes complete notes, covering Input & Output functions, Operators, and other related topics, along with MCQs, short-answer questions, and long-answer questions to help students prepare for exams efficiently.

📚 Important MCQs – Unit 2 User Interaction

1. scanf is a ____ in C programming language.

a) Keyword
b) Library
c) Function ✅
d) None of them

2. Which operator has the highest precedence in C programming?

a) / ✅
b) =
c) >
d) !

3. Which function in C is used to display formatted output on the screen?

a) scanf
b) printf
c) gets
d) puts

4. Which relational operator means “not equal to” in C programming?

a) =!
b) != ✅
c) <>
d) =/=

Short Questions – Unit 2 User Interaction

1. What is the difference between scanf and getch?

Answer:

  • scanf is used to take input from the user for different data types like int, float, char, and strings. After entering the input, the user needs to press the Enter key for the program to read the value.

  • getch is used to take a single character input without displaying it on the screen. It does not require pressing the Enter key.

Example:

int num;
scanf(“%d”, &num); // Reads an integer
getch(); // Reads a single character silently

2. What are escape sequences? Why do we need them?

Answer:

  • Escape sequences are special codes used in C programming that change the normal behavior of the printf() output.

  • They always start with a backslash (\) followed by a character.

  • We use escape sequences to format the output, such as moving to a new line, adding a tab space, or displaying special characters.

Examples:

  • \n → Moves the cursor to a new line

  • \t → Adds a tab space

Example in code:

printf(“Hello\nWorld”); // Prints Hello in one line and World in the next
printf(“Name:\tJohn”); // Prints Name: John with a tab space

3. What is the difference between unary operators and binary operators?

Answer:

  • Unary operators work on a single operand. They perform operations like negation or logical NOT.

    • Example: !x (logical NOT), -x (negation)

  • Binary operators work on two operands. They perform operations like addition, subtraction, or logical AND.

    • Example: x + y (addition), x && y (logical AND)

Key Point:
Unary operators affect one value, while binary operators require two values to perform an operation.

4. What is the main difference between scanf() and getch() functions?

Answer:

  • scanf() can take input of different data types like integers, floats, characters, and strings. After entering the input, the user must press the Enter key for the program to read the value.

  • getch() takes only a single character as input and does not require pressing the Enter key. It also does not display the character on the screen when it is pressed.

Example:

int num;
char ch;
scanf(“%d”, &num); // Reads an integer (requires Enter)
ch = getch(); // Reads a single character silently

Key Point:
scanf() is used for reading multiple data types with Enter, while getch() is ideal for reading single key presses immediately without displaying them.

Long Questions – Unit 2 User Interaction

Q1: What is input and output in computer programming?

Introduction:
In computer programming, input and output (I/O) operations allow communication between the program and the user. Input lets the program receive data, while output displays the processed results. These operations are essential for interactive and practical applications.

Definition:

  • Input: The process of providing data to a program from an external source (keyboard, file, etc.).
  • Output: The process of sending or displaying results from a program to the screen, printer, or file.

Explanation in C Language:

1. Input in C Language:

  • Performed using the scanf() function.
  • Requires format specifiers to define the type of data being read.

2. Output in C Language:

    • Performed using the printf() function.

    • Can display text, numbers, and variable values.

Example:

#include <stdio.h>
void main() {
int age;
printf(“Enter your age:”); // Output prompt
scanf(“%d”, &age); // Input from user
printf(“Your age is %d”, age); // Output result
}

Example Explanation:

  1. printf("Enter your age:"); ⇒ Displays a message asking the user to enter their age.

  2. scanf("%d",&age); ⇒ Reads an integer value from the user and stores it in age.

  3. printf("Your age is %d", age); ⇒ Prints the entered age on the screen.

Closing Statement:
I/O operations are the backbone of interactive programming, enabling smooth communication between the computer and the user.

📥 Download PDF

Download the complete chapter notes in PDF for easy learning and quick exam revision.

English Medium

Skip to PDF content

These notes are in English and include all MCQs, short-answer questions, and long-answer questions for Class 10 Computer Science Unit 2 – User Interaction.

Urdu Medium

Skip to PDF content

These notes are translated into Urdu and cover all MCQs, short-answer questions, and long-answer questions for Class 10 Computer Science Unit 2 – User Interaction.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top