Section B Symbols: Yes No
/ \
Q1.(a)Pseudocode • Oval (Terminal): Represents the start or end of the program.
[Are you above 18?] [You cannot drive]
• Definition: A plain English (or human-readable) way to write the steps of a program • Parallelogram (Input/Output): Denotes input operations (e.g., reading data) or output / \
without worrying about programming syntax. operations (e.g., printing results). Yes No
• Purpose: To focus on logic before coding. • Rectangle (Process): Represents processing steps or computations (e.g., arithmetic
/ \
• Rules: operations, variable assignments).
[You can drive] [You cannot drive]
• Use simple, clear sentences
• Diamond (Decision): Indicates a decision point where the program flow branches based on a
• Use keywords like IF, ELSE, WHILE, FOR, PRINT
condition (e.g., if-else statements, loops).
• No need for exact code formatting
• Arrows (Flowlines): Connect the symbols and indicate the direction of the program's Q2. (a) Relational Operators
Example: Find the area of a rectangle execution flow.
START Definition:
INPUT length, width Relational operators are used to compare two values. They return a boolean result – either true or false.
Area = length × width
Common Relational Operators:
PRINT area
• > (greater than)
END • < (less than)
(b) Algorithm • >= (greater than or equal to)
• <= (less than or equal to)
• Definition: A finite, step-by-step procedure to solve a problem. • == (equal to)
• Purpose: To describe the exact sequence of actions to perform. • != (not equal to)
• Properties of a good algorithm:
1. Finiteness – Must end after a limited number of steps Example :
2. Definiteness – Steps must be clear and unambiguous
3. Input – Zero or more inputs int a = 10, b = 20;
4. Output – At least one result
5. Effectiveness – Steps must be doable with available resources
if (a < b) {
Example: Find the area of a rectangle
printf(“a is smaller than b”);
Step 1: Start
Step 2: Input length and width }
(d) Decision Trees
Step 3: Multiply length by width and store in area Output: a is smaller than b
A decision tree is a diagram that helps you make decisions based on different conditions.
Step 4: Display area
It looks like a branching tree where:
Step 5: Stop
• Nodes = Questions or conditions (b) Logical Operators
(c) Flowcharts • Branches = Possible answers (Yes/No, True/False)
Flowcharts are graphical representations of algorithms or processes used in C programming • Leaves = Final outcomes or actions Definition:
(and other programming languages) to visualize the logical flow of a program. They help in
understanding, designing, and debugging C code by illustrating the sequence of operations, Logical operators are used to combine two or more conditions. They return true/false.
decision points, and input/output.
Purpose: EXAMPLE: Types:
Flowcharts serve as a program planning tool, making it easier to understand the logic and flow
of a C program before or during coding. [Do you have a license?] • && (Logical AND): True only if both conditions are true.
/ \ • || (Logical OR): True if at least one condition is true.
1 2 3
• ! (Logical NOT): Reverses the result. • Increment (++) → increases value by 1 • Used for defining constants and macros before the program starts.
• Decrement (--) → decreases value by 1 • Example:
Example: • Unary minus (-) → changes sign of a number
• Logical NOT (!) → inverts boolean value #define PI 3.14159
int age = 25, marks = 80;
Example:
if (age > 18 && marks > 50) {
int x = 5; 4. Global Declaration Section
printf(“Eligible”); • Variables and functions declared here can be accessed anywhere in the program.
printf(“%d”, ++x); // Pre-increment → prints 6 • Example:
}
printf(“%d”, x--); // Post-decrement → prints 6, then x becomes 5 int total; // Global variable
Output: Eligible
Output: 66 (and finally x = 5)
5. Main() Function Section
(c) Conditional Operator (Ternary Operator) • Every C program must have a main() function.
Q3. Structure of the C Program: The basic structure of a C program is divided into 6 parts which makes • This is where execution starts.
Definition: it easy to read, modify, document, and understand in a particular format. C program must follow the • Structure of main:
below-mentioned outline in order to successfully compile and execute. Debugging is easier in a well-
The conditional operator ?: is also called a ternary operator because it works on three operands. structured C program. int main() {
Syntax: Sections of the C Program: // Local variable declarations
Condition ? expression1 : expression2 1. Documentation Section (Comments)
// Statements
• Used to write information about the program, like purpose, author, or date.
• If condition is true, expression1 executes. • Written using // (single line) or /* … */ (multi-line). return 0;
• If condition is false, expression2 executes. • Example:
}
Example: /* Program to find the sum of two numbers*/
int a = 10, b = 20; Or
6. Subprograms (User-Defined Functions)
int max = (a > b) ? a : b; // Program to find the sum of two numbers • Functions written by the programmer for specific tasks.
• Help in code reusability and modularity.
printf(“Maximum = %d”, max); • Example:
Output: Maximum = 20 2. Link Section (Preprocessor Directives) int add(int x, int y) {
• Includes header files that contain standard functions.
• Example: return x + y;
(d) Unary Operators #include <stdio.h> // For printf and scanf }
#include <math.h> // For mathematical functions
Definition: • Structure of C Program with example
Unary operators work on a single operand only. Example: Below C program to find the sum of 2 numbers:
Types: 3. Definition Section
// Documentation
4 5 6
/** { printf(“Largest number = %d\n”, c);
*File: sum.c return y + X; }
*Author: you } return 0;
*Description: program to find sum. }
*/ Output Output: Enter three numbers: 15 25 10
Sum: 75 Largest number = 25
// Link Explanation of the above Program Explanation
#include <stdio.h> Below is the explanation of the above program. With a description explaining the program’s meaning and 1. Program asks user to enter three numbers.
use. 2.
// Definition • If and else if conditions compare the numbers.
• If a is greater than or equal to both b and c, then a is largest.
#define X 20 • Else if b is greater than or equal to both, then b is largest.
Q4. This the ‘C ‘program to find the largest number out of three numbers. • Otherwise, c is largest.
3. Result is printed.
#include <stdio.h>
// Global Declaration
int main() {
int sum(int y); Q5. Program to print following pattern:
int a, b, c;
(A) Right-angled triangle
// Input #include <stdio.h>
// Main() Function
printf(“Enter three numbers: “); int main() {
int main(void) int I, j, n;
scanf(“%d %d %d”, &a, &b, &c);
{ // Input number of rows
// Process & Output printf(“Enter number of rows: “);
scanf(“%d”, &n);
int y = 55;
if (a >= b && a >= c) {
// Right-angled triangle
printf(“Sum: %d”, sum(y)); for (I = 1; I <= n; i++) {
printf(“Largest number = %d\n”, a); for (j = 1; j <= I; j++) {
return 0; printf(“* “);
} }
} printf(“\n”);
else if (b >= a && b >= c) { }
printf(“Largest number = %d\n”, b); return 0;
// Subprogram }
}
int sum(int y) Output:
else {
7 8 9
Enter number of rows: 5 ***** Float 4
Double 8
* **** Char 1
** *** Q5.
Pre- increment (++x) Post- increment (x++)
*** ** Increments the value before using it Increments the value after using it
Eg.: Int x = 5; y = ++x; → x=6, y=6 Eg.: Int x = 5; y = x++; → x=6, y=5
**** *
***** SECTION ‘A’
(B) Inverted Right-Angled Triangle Q1.
#include <stdio.h> Keywords Identifiers
Reserved words with predefined use Names given by programmer (variables,
int main() { functions)
Defined by C language Defined by programmer
int I, j, n; Int, if, while, return Age, sum, totalMarks
No, cannot use as names Yes, programmer can define
// Input number of rows Only 32 (in C) Unlimited
printf(“Enter number of rows: “); Q2. Two common unformatted Input/ Output functions are:
scanf(“%d”, &n); • Input
(i) scanf() – Takes value form user
// Inverted right-angled triangle (ii) getchar() – Reads a single character from the keyboard.
• Output
for (I = n; I >= 1; i--) { (i) printf() – Use for print results
(ii) putchar() – Writes a single character to the screen.
for (j = 1; j <= I; j++) {
Q3.
printf(“* “);
Symbolic constants are names given to fixed values which cannot be changed during program execution.
} They make the program more readable and easier to maintain.
printf(“\n”); Example:
} #define PI 3.14159
return 0; #define MAX 100
} Here, PI and MAX are symbolic constants.
OUTPUT Q4. Primitive data types in C and their size
Enter number of rows: 5 Data Type Size (in bytes)
Int 2 to 4 (Depends on System)
10 11 12