Class 10th Computer Science Notes 2026 | User Interaction in C Language - Short Questions & Anserws

 



Chapter: User Interaction in C Language 10th

Is chapter mein hum seekhenge ke C program mein user se data kaise liya jata hai (Input) aur screen par results kaise dikhaye jate hain (Output). Saath hi hum mukhtalif "Operators" (jaise math aur logic symbols) ke baare mein bhi parhain ge jo computer ko calculations karne mein madad dete hain.


Section 1: Basic Input and Output

1. Define a computer.

  • Simple Answer: A computer is an electronic machine that takes data (input), processes it, and gives a result (output).

2. What is the printf() function?

  • Simple Answer: It is a built-in function used to show output on the screen. The name comes from "print formatted".

3. What is a format specifier?

  • Simple Answer: These are special codes used to tell the computer which type of data (like numbers or letters) we are using. They always start with a % sign.

4. Common Format Specifiers:

| Data Type | Format Specifier |

| :--- | :--- |

| int (Whole numbers) | %d or %i |

| float (Decimal numbers) | %f |

| char (Single letter) | %c |

5. What is the purpose of scanf()?

  • Simple Answer: It is a function used to take input from the user and store it in variables.

6. What is a common mistake in scanf()?

  • Simple Answer: The most common mistake is forgetting the & (ampersand) sign before the variable name.

7. What is getch() and which library is used for it?

  • Simple Answer: getch() is used to read a single character from the user. It is usually used to pause the screen. We must include <conio.h> to use it.

8. What is a statement terminator?

  • Simple Answer: In C, the semicolon (;) is called the statement terminator. It tells the computer that a line of code has ended.


Section 2: Escape Sequences

9. What is an escape sequence?

  • Simple Answer: These are special characters used inside printf() to change how output looks. They always start with a backslash (\).

10. Define \n and \t.

  • \n (New Line): Moves the cursor to the start of the next line.

  • \t (Tab): Moves the cursor 8 spaces forward (like a Tab key).


Section 3: Operators and Expressions

11. What is an operator?

  • Simple Answer: An operator is a symbol (like +, -, *) that tells the computer to perform a specific mathematical or logical task.

12. Differentiate between Unary and Binary operators.

  • Unary Operator: Works with only one value (e.g., -5 or !).

  • Binary Operator: Works with two values (e.g., a + b).

13. What is the Modulus operator (%)?

  • Simple Answer: It divides two numbers and gives the remainder (leftover value) as the answer.

  • Example: 14 % 3 = 2.

14. What are Relational Operators?

  • Simple Answer: These are used to compare two values to see if they are equal, greater, or smaller (e.g., >, <, ==).

15. Assignment (=) vs. Equal to (==) Operator:

  • = (Assignment): Used to store a value in a variable.

  • == (Equal to): Used to check if two values are equal.

16. What is Operator Precedence?

  • Simple Answer: It is the order or "rank" that decides which operator is solved first in a long sum.

  • Order: Brackets () are 1st, then * / %, then + -, and = is last.


Section 4: Logical Operators

17. Define Logical Operators.

  • Simple Answer: These are used to check multiple conditions at once.

    • && (AND): True only if both sides are true.

    • || (OR): True if at least one side is true.

    • ! (NOT): Reverses the result (True becomes False and vice versa).


Section 5: Important C Program

Program to Swap (Exchange) two numbers:

C
#include<stdio.h>
#include<conio.h>
void main() {
    int a = 2, b = 3, temp;
    temp = a;   // a ki value temp mein rakhi
    a = b;      // b ki value a mein rakhi
    b = temp;   // temp ki value b mein rakhi
    printf("a = %d, b = %d", a, b);
    getch();
}



Section: Mathematical Operators

18. Write a program that swaps the values of two integer variables.

  • Simple Answer: Swapping means exchanging values. If $a=2$ and $b=3$, after swapping $a=3$ and $b=2$.

  • Logic: We use a third variable temp as a temporary box.

19. What is the use of an Arithmetic operator?

  • Simple Answer: Arithmetic operators are used to perform basic math like addition, subtraction, multiplication, and division on data.

20. What is the Division operator (/)?

  • Simple Answer: It is used to divide the left number by the right number.

  • Example: result = 10 / 2; (Result will be 5).

21. What is the Multiplication operator (*)?

  • Simple Answer: It is a binary operator used to find the product of two numbers.

  • Example: 5 * 5 = 25.

22. Difference between Division (/) and Multiplication (*) operators?

  • Division: Splits a number into parts.

  • Multiplication: Adds a number to itself multiple times.

23. What is an Addition operator (+)?

  • Simple Answer: It calculates the sum of two numbers.

  • Example: 10 + 10 = 20.

24. Why are a = a + 1 and a-- used?

  • a = a + 1: Used to increase the value of 'a' by 1 (Increment).

  • a--: Used to decrease the value of 'a' by 1 (Decrement).

25. What is the Subtraction operator (-)?

  • Simple Answer: It subtracts the right number from the left number.

  • Example: 20 - 15 = 5.

26. What is the Modulus operator (%)?

  • Simple Answer: It divides two integers and gives only the remainder.

  • Example: 14 % 3 gives 2.

27. Common mistake while writing arithmetic statements in C?

  • Simple Answer: In C, we cannot write $6y$ or $x^3$ like in math. We must write 6 * y and x * x * x.


Section: Logical and Relational Operators

28. Why are relational operators used?

  • Simple Answer: They are used to compare two values (e.g., is $A > B$?) to find the relationship between them.

29. Difference between Assignment (=) and Equal to (==) operator?

  • =: Puts a value into a variable.

  • ==: Compares two values to see if they are the same.

30. Difference between Logical and Arithmetic operators?

  • Arithmetic: Solves math (Result is a number like 10, 20).

  • Logical: Checks conditions (Result is True or False).

31. Define Logical operator.

  • Simple Answer: These operators help computer take decisions by checking multiple conditions (AND, OR, NOT).

32. Names of Logical operators:

  1. && (Logical AND)

  2. || (Logical OR)

  3. ! (Logical NOT)

33. What is the AND operator (&&)?

  • Simple Answer: It gives "True" only if all conditions are true.

Image of AND gate truth tableShutterstock

34. What is the OR operator (||)?

  • Simple Answer: It gives "True" if at least one condition is true.

Image of OR gate truth tableShutterstock

35. What is the NOT operator (!)?

  • Simple Answer: It reverses the result. It makes True → False, and False → True.

Image of NOT gate truth tableShutterstock


Section: Operator Precedence

36. What is Operators' Precedence?

  • Simple Answer: It is a rule that tells the computer which operator to solve first when there are many operators in one line.

37. Operator Precedence Table (Rank wise):

| Rank | Operator | Type |

| :--- | :--- | :--- |

| 1 | () | Brackets |

| 2 | ! | Logical NOT |

| 3 | * , / , % | Multiply, Divide, Modulus |

| 4 | + , - | Add, Subtract |

| 5 | > , < , >= , <= | Relational |

| 6 | == , != | Equality |

| 7 | && | Logical AND |

| 8 | || | Logical OR |

| 9 | = | Assignment |

38. Define Ternary operator.

  • Simple Answer: It is a special operator in C that works with three values (operands). It is a short way of writing an if-else condition.




0 Comments