Computer Science Notes PDF 12th Class:
C Programming Theory – Short Questions and Answers
1. Define Syntax Error with Any Two Examples:
A syntax error occurs when the code violates the grammar
rules of the C language.
Examples:
● int 2num = 5; // Invalid variable name
● printf("Hello") // Missing semicolon
2. Why is C Called a Case-Sensitive Language? Give One Example:
C treats uppercase and lowercase letters as different.
Example: int NUM; and int num; are two distinct
variables.
3. Basic Structure of a C Program:
c
CopyEdit
#include <stdio.h>
int main() {
// Code
return 0;
}
4. Define #include or #define:
● #include: Includes header files. Example: #include
<stdio.h>
● #define: Defines constants. Example: #define PI
3.14
5. What is IDE (Integrated Development Environment)?
An IDE is a software application that provides comprehensive
facilities to programmers for software development. Example:
Code::Blocks, Dev-C++.
6. Rules to Declare Identifiers:
● Must begin with a letter or underscore
● Cannot be a keyword
● No special characters or spaces
● Case-sensitive
● Can include letters, digits, and underscores
7. Five Escape Sequences in C:
● \n – New Line
● \t – Tab
● \\ – Backslash
● \" – Double Quote
● \a – Alert (Beep)
8. Five Format Specifiers/Conversions:
● %d – Integer
● %f – Float
● %c – Character
● %s – String
● %lf – Double
9. Operator Precedence in C:
1.Parentheses ()
2.Unary ++, --, !
3.Multiplicative *, /, %
4.Additive +, -
5.Relational <, >, <=, >=
6.Equality ==, !=
7.Logical &&, ||
8.Assignment =, +=, -=
9.Comma ,
10. Four Standard Library Functions:
● printf()
● scanf()
● strlen()
● sqrt()
11. What is Address of Operator (&)?
Used to get the memory address of a variable.
Example:
c
CopyEdit
int a = 5;
printf("%p", &a);
12. Unconditional Control Transfer (goto):
Transfers control to a labeled statement.
Example:
c
CopyEdit
goto label;
// ...
label:
printf("Jumped here");
13. if-else Conditional Control Structure:
Used for decision-making.
Example:
c
CopyEdit
if (x > 0)
printf("Positive");
else
printf("Negative");
14. What is a Function? Three Uses:
A block of code that performs a task.
Uses:
● Code reuse
● Modularity
● Simplifies debugging
15. Function Prototype/Declaration:
Declares the function before its use.
Example: int add(int, int);
16. What is an Array? How is it Declared?
An array is a collection of variables of the same type.
Example: int numbers[5];
17. What is a String? Examples:
A string is a sequence of characters ending with a null
character \0.
Examples: "Hello", "C Programming"
18. Advantages of Array:
● Stores multiple values
● Saves memory
● Easy data access
● Efficient searching/sorting
● Reduces code redundancy
19. What is a Computer Language?
A language used to instruct computers.
Examples: C, Java, Python
20. Types of Computer Languages:
● Machine Language
● Assembly Language
● High-Level Language
21. Types of Programming Languages by Structure:
● Procedural (C)
● Object-Oriented (C++, Java)
● Functional (Haskell)
● Logic-based (Prolog)
22. What is a Computer Program? Example:
A set of instructions for a computer.
Example: printf("Hello");
23. Define Software:
Software is a set of instructions that direct a computer to
perform specific tasks.
24. Historical Background of C Language:
Developed by Dennis Ritchie in 1972 at Bell Labs. It evolved
from the B language.
25. Writing Algorithm Using Pseudocode:
Example: Add Two Numbers
mathematica
CopyEdit
Start
Input a, b
Sum = a + b
Print Sum
End
26. Purpose and Symbols of Flowchart:
Flowcharts visually represent an algorithm.
Symbols:
● Start/End – Oval
● Process – Rectangle
● Decision – Diamond
● Input/Output – Parallelogram
27. What is a Variable? Rules to Define:
A variable is a named memory location.
Rules: Start with a letter, no spaces, no special characters,
not a keyword.
28. What is a Constant?
A constant is a fixed value that doesn’t change during
execution. Used to avoid magic numbers.
29. What is a Header File?
Contains predefined functions.
Example: #include <math.h>
30. What is a C Statement?
A command in a C program.
Example: x = x + 1;
31. Purpose of Keywords in C:
Reserved words used for specific purposes.
Examples: int, return, if
32. Preprocessor Directive with Example:
Instructions to the compiler.
Example: #define MAX 100
33. What are Identifiers? Example:
Names used to identify variables, functions, etc.
Example: main, sum
34. Input Statement Example:
c
CopyEdit
scanf("%d", &num);
35. Output Statement Example:
c
CopyEdit
printf("Result: %d", num);
36. What is a Format Specifier?
Indicates data type during input/output.
Examples: %d, %f, %c, %s
37. Address Operator Code Example:
c
CopyEdit
int a = 10;
printf("%p", &a);
38. Methods to Write Comments in C:
● Single-line: // comment
● Multi-line: /* comment */
39. Define and Explain Escape Sequences:
Special characters with \\ used for formatting output.
Examples: \n, \t, \\, \"
40. Define Data Type. Types in C:
Specifies the type of data.
Types: int, float, char, double
41. What is an Operator? Types in C:
Performs actions on variables.
Types: Arithmetic, Relational, Logical, Assignment, Bitwise
42. Control Structures Used in C:
● Sequence
● Selection (if, switch)
● Iteration (for, while, do-while)
● Jump (break, continue, goto)
43. Iteration or Repetition Control Structure:
Repeats a block of code.
Examples: for, while, do-while
44. Types of I/O Functions in C:
Input: scanf(), getchar()
Output: printf(), putchar()
45. Define Function and Its Types:
A function is a block of reusable code.
Types:
● Library Functions
● User-Defined Functions
● Recursive Functions
46. Programmer/User-Defined Functions Example:
c
CopyEdit
int add(int a, int b) {
return a + b;
}
47. Advantages of User-Defined Functions:
● Reusability
● Modularity
● Easy debugging
● Improved readability
● Code reduction