Top Banner Ad
ACS101 · 2025-2615 Questions

Programming Languages — 2025-26

Section A

2 Marks Each · 6 questions
Q1a2MUnit 1 — Data types
Core Concept

Write the fundamental data types used in C Programming, along with their range, byte size and format specifier.

The fundamental C types are character, integer, floating point and double precision floating point. Variants such as short, long and signed or unsigned change range and storage size. Format specifiers tell input and output functions how to interpret each value, for example character, decimal integer, float and double.

Key Points

  • Four fundamental types
  • Variants change range
  • Format specifiers interpret values
Q1c2MUnit 1 — operators (arithmetic, relational, logical)
PredictedRepeated

What are logical operators?

Concept / Given Data

Logical operators (&&, ||, !) evaluate Boolean expressions and short‑circuit, whereas bitwise operators (&, |, ^, ~, <<, >>) perform bit‑level manipulation on integer operands. Logical operators return 0 (false) or 1 (true). Bitwise operators work on the binary representation of the operands.

Key Formula / Principle: a&b,a∣b,ab, a,a<<n,a>>na \& b, a | b, a ^ b, ~a, a<<n, a>>n

Step‑by‑Step Solution / Derivation / Working

  1. Logical AND (&&) – evaluates left operand; if false, right operand is not evaluated.

    int x = 5, y = 0;
    if (x>0 && y>0) printf("both positive");
    

    Here y>0 is not evaluated because x>0 is true but y>0 is false, resulting in the condition being false.

  2. Logical OR (||) – evaluates left operand; if true, right operand is skipped.

    if (x>0 || y>0) printf("at least one positive");
    

    Since x>0 is true, y>0 is not checked.

  3. Logical NOT (!) – inverts Boolean value.

    if (!(x==5)) printf("x is not 5");
    
  4. Bitwise AND (&) – performs AND on each bit.

    int a = 0b1100, b = 0b1010; // 12 and 10
    int r = a & b; // 0b1000 = 8
    
  5. Bitwise OR (|) – performs OR on each bit.

    int r = a | b; // 0b1110 = 14
    
  6. Bitwise XOR (^) – exclusive OR.

    int r = a ^ b; // 0b0110 = 6
    
  7. Bitwise NOT (~) – flips all bits.

    int r = ~a; // 0b0011 (in 4‑bit view) = -13 in two's complement
    
  8. Left Shift (<<) – multiplies by powers of two.

    int r = a << 1; // 0b11000 = 24
    
  9. Right Shift (>>) – divides by powers of two (arithmetic shift for signed).

    int r = a >> 1; // 0b0110 = 6
    

Diagram (optional):

flowchart TD
  A[Logical AND] --> B[Short‑circuit]
  A --> C[Returns 0/1]
  D[Bitwise AND] --> E[Bit‑level AND]
  D --> F[Returns integer]

Result: Logical operators are used for control flow and decision making, yielding Boolean values, while bitwise operators manipulate individual bits of integer data, useful in low‑level programming and embedded systems.

Tip from Examiner: Remember that logical operators short‑circuit; bitwise operators do not. Also, logical operators always yield `0` or `1`, whereas bitwise operators preserve the operand type.

Key Points

  • Logical operators return 0/1 and short‑circuit
  • Bitwise operators work on binary representation
  • && skips right side if left is false
  • || skips right side if left is true
  • ! inverts Boolean value
  • &, |, ^, ~, <<, >> manipulate bits
Q1d2MUnit 1 — Type conversion
Survival ModeRepeated

Differentiate between implicit and explicit type conversion in C.

Implicit conversion is performed automatically by the compiler when a value is assigned to a wider compatible type. Explicit conversion, called casting, is requested by the programmer with a cast operator. Casting is useful when a deliberate narrowing conversion is needed, but it can lose data if the target type is too small.

Key Points

  • Implicit is automatic
  • Explicit is programmer requested
  • Casting may lose data
Q1e2MUnit 2 — Loops — for
Survival ModePredictedRepeated

Write the output of the following code: #include<stdio.h> int main() { int a = 0, i = 0, b; for (i = 0; i < 5; i++) { a++; if (i == 3) break; } printf("%d", a); return 0; }

The loop executes four times. The counter starts at zero and is increased after each pass, while the separate variable is increased at the start of every pass. When the counter reaches three the break statement exits the loop immediately. The final printed value is therefore four, and the update after break is not performed.

Key Points

  • Four iterations
  • Break at counter three
  • Printed result is four
Q1f2MUnit 2 — Recursion — factorial and Fibonacci (simple examples only) Real connect: Control flow is the brain of every program — from traffic signal logic to drone autopilot decision-making
Core Concept

What is a recursive function? Explain with an example.

A recursive function is a function that invokes itself while solving a task. It divides the task into a simple stopping case and a smaller repeated case. For factorial, the stopping case returns one for zero or one, and the repeated case multiplies the current number by the factorial of the number before it.

Key Points

  • Invokes itself
  • Stopping and repeated cases
  • Factorial illustration
Q1g2MUnit 3 — File Handling Real connect: Arrays store sensor readings
Survival ModePredicted

List various file opening modes.

File opening modes tell the library how a file will be used. Read mode opens an existing file for input. Write mode creates a new file or empties an existing one. Append mode adds data at the end. Update modes allow both reading and writing, and a trailing character selects text or binary handling.

Key Points

  • Read mode
  • Write and append modes
  • Text or binary handling

Section B

7 Marks Each · 2 questions
Q2c7MUnit 3 — Structures
Core Concept

Differentiate between structure and union with suitable example.

1. Definition and scope: C constructs provide the vocabulary for representing data and controlling execution: declarations define storage, operators transform values, and control statements choose the path of computation.

2. Scored mechanism:

  • A data type fixes the set of legal values and operations, such as int, float, char, string, or list.
  • Arithmetic, relational, logical, and bitwise operators have distinct precedence and associativity.
  • Selection statements use conditions; iteration statements repeat a block until a termination condition is met.
  • Functions accept parameters, return values, and reduce duplication through modular decomposition.
  • Recursion solves a problem by calling itself on a smaller instance with a clear base case.
  • Arrays store homogeneous elements in contiguous memory addressable by an index; Python lists are dynamic.

3. Marking points — Structures:

Construct Purpose Example
Sequence execute in order assignments
Selection choose a branch if / else
Iteration repeat a block for / while
Function reuse logic def / return

4. Procedure:

  1. Identify the base definition needed for the question.
  2. Apply the relevant rule or formula to the given values.
  3. Trace each step with the given input.
  4. State the final value.

5. Application to the asked question: Differentiate between structure and union with suitable example.

  • Identify the base definition needed for the question.
  • Apply the relevant rule or formula to the given values.
  • Trace each step with the given input.

Structures, unions and linked data. A structure is a user defined type that groups related members which may have different types. It is declared with a tag and variables of that type can be created individually or as an array. Members are accessed with the dot operator, or with the arrow operator when working through a pointer. An array of structures is useful for records such as students or employees, where each element holds a name, designation, salary, department and city. A program can scan such an array and print only records whose salary exceeds a chosen limit. A union resembles a structure but all members share the same memory, so only one member can hold a valid value at a time. It saves space when alternatives are exclusive, for example storing different kinds of student information in one record. A self referential structure contains a pointer to another structure of the same type, which is the basis of a linked list. Each node holds data and a link to the next node, and a head pointer identifies the start. A good answer defines each term, gives a declaration, explains member access and shows a small traversal. It should state the difference between structure and union in terms of memory allocation and valid members. Mentioning that dynamic allocation allows a linked list to grow during execution connects the idea to practical programming.

Result: State the traced result from the given data.

Tip from Examiner: State the concept, show the C code or flowchart with clear comments, trace one sample input, and mention the common mistake or boundary condition an examiner will look for.
Key Formula / Principle: $O(1)$ $\&$ $a\& b, a|b, a^b$

Key Points

  • Structures
  • A data type fixes the set of legal values and operations, su
  • Arithmetic, relational, logical, and bitwise operators have
  • Selection statements use conditions; iteration statements re
  • Functions accept parameters, return values, and reduce dupli
  • State the traced result from the given data.
Q2d7MUnit 2 — call by value
Core Concept

Differentiate between call by value and call by reference parameter passing in C using example.

1. Definition and scope: C programs use declarations, expressions, control statements and functions to solve the stated problem.

2. Scored mechanism:

  • Identify the declared types and values before applying the operator.
  • Apply C precedence and associativity when an expression has several operators.
  • Match the format specifier or file mode to the data being handled.
  • Arithmetic, relational and logical operators follow fixed precedence and associativity.
  • Selection and iteration statements control the order of execution.
  • Functions and arrays organise reusable logic and related data.

3. Marking points — call by value:

C feature Purpose Example
Declaration reserves typed storage int a;
Control chooses or repeats actions if / for
Function packages reusable work return a+b;

4. Governing relation: Evaluate the given expression or statement using the declared types and C operator rules.

5. Application to the asked question: Differentiate between call by value and call by reference parameter passing in C using example.

  • Write the relevant C statement or expression.
  • Trace it with the supplied values.
  • State the resulting value or output.

Functions and parameter passing. A function is a named block of code that performs a specific task. It has a declaration that tells the compiler its name, return type and parameter types, and a definition that supplies the body. Calling a function transfers control to that body, and a return statement sends a value back to the caller. Functions make programs modular, easier to test and easier to reuse. C programs use library functions such as printf and user defined functions written by the programmer. Parameters can be passed in different ways. In call by value, the function receives copies of the arguments, so changing a parameter inside the function does not change the caller's variable. In call by reference, simulated in C by passing addresses, the function uses pointers to access the original variables, so changes are visible after the call. A swap program illustrates the difference clearly: passing values leaves the original variables unchanged, while passing addresses exchanges them. A good answer defines a function, distinguishes declaration and definition, explains return values and compares the two parameter passing methods with a small example. It should mention that arrays are passed as pointers to their first element, which is why a function can modify array contents. Mentioning that call by value protects the caller from accidental changes while pointer passing is needed when multiple results must be returned adds judgement.

Result: Give the computed value or output for the stated program.

Tip from Examiner: State the concept, show the C code or flowchart with clear comments, trace one sample input, and mention the common mistake or boundary condition an examiner will look for.
Key Formula / Principle: $O(1)$ $\&$ $a\& b, a|b, a^b$

Key Points

  • call by value
  • Identify the declared types and values before applying the operator.
  • Apply C precedence and associativity when an expression has several operators.
  • Match the format specifier or file mode to the data being handled.
  • State the traced result from the given data.
  • Give the computed value or output for the stated program.

Section C

7 Marks Each · 7 questions
Q3b7MUnit 3 — Simple operations — find max
Core Concept

Write an algorithm to find the greatest of three numbers. Also draw the flowchart for the algorithm.

1. Definition and scope: C programs use declarations, expressions, control statements and functions to solve the stated problem.

2. Scored mechanism:

  • Identify the declared types and values before applying the operator.
  • Apply C precedence and associativity when an expression has several operators.
  • Match the format specifier or file mode to the data being handled.
  • Arithmetic, relational and logical operators follow fixed precedence and associativity.
  • Selection and iteration statements control the order of execution.
  • Functions and arrays organise reusable logic and related data.

3. Marking points — Simple operations find max:

C feature Purpose Example
Declaration reserves typed storage int a;
Control chooses or repeats actions if / for
Function packages reusable work return a+b;

4. Governing relation: Evaluate the given expression or statement using the declared types and C operator rules.

5. Application to the asked question: Write an algorithm to find the greatest of three numbers. Also draw the flowchart for the algorithm.

  • Write the relevant C statement or expression.
  • Trace it with the supplied values.
  • State the resulting value or output. Diagram instruction: Draw the labelled figure/flow described above with inputs, control path, and output.

Finding maximum, minimum and average. Simple numeric tasks build the foundation of programming. To find the largest of several numbers, store the first value as the current maximum, then compare every remaining value with it and replace the maximum when a larger value is found. The same idea with the opposite comparison finds the smallest value. To compute an average, add all values in a running total and divide by the count after the loop. Care is needed with integer division, because dividing an integer total by an integer count discards the fractional part. Casting one operand to a floating point type preserves the fraction. When the values are stored in an array, a loop can process them and a function can receive the array and its length. An algorithm for the greatest of three numbers reads three values, compares the first two, then compares the winner with the third and prints the result. Its flowchart uses two decision diamonds and one output box. A good answer states the algorithm in steps, gives a program, and traces it with a sample such as three, nine and five. It should explain initialising the maximum from the first element rather than from zero, because negative inputs would otherwise fail. Mentioning how the same pattern applies to sensor readings or marks connects the exercise to realistic data processing.

Result: Give the computed value or output for the stated program.

Tip from Examiner: State the concept, show the C code or flowchart with clear comments, trace one sample input, and mention the common mistake or boundary condition an examiner will look for.
Flowchart for greatest of three numbers read a, b, c a greater b yes no b greater c print aprint c when yes, print b when no
Key Formula / Principle: $O(1)$ $\&$ $a\& b, a|b, a^b$

Key Points

  • Simple operations — find max
  • Identify the declared types and values before applying the operator.
  • Apply C precedence and associativity when an expression has several operators.
  • Match the format specifier or file mode to the data being handled.
  • State the traced result from the given data.
  • Give the computed value or output for the stated program.
Q4a7MUnit 2 — Control Statements
Survival ModeRepeated

Write a program to discuss the use of break in a switch case statement.

1. Definition and scope: C constructs provide the vocabulary for representing data and controlling execution: declarations define storage, operators transform values, and control statements choose the path of computation.

2. Scored mechanism:

  • A data type fixes the set of legal values and operations, such as int, float, char, string, or list.
  • Arithmetic, relational, logical, and bitwise operators have distinct precedence and associativity.
  • Selection statements use conditions; iteration statements repeat a block until a termination condition is met.
  • Functions accept parameters, return values, and reduce duplication through modular decomposition.
  • Recursion solves a problem by calling itself on a smaller instance with a clear base case.
  • Arrays store homogeneous elements in contiguous memory addressable by an index; Python lists are dynamic.

3. Marking points — Control Statements:

Construct Purpose Example
Sequence execute in order assignments
Selection choose a branch if / else
Iteration repeat a block for / while
Function reuse logic def / return

4. Procedure:

  1. Identify the base definition needed for the question.
  2. Apply the relevant rule or formula to the given values.
  3. Trace each step with the given input.
  4. State the final value.

5. Application to the asked question: Write a program to discuss the use of break in a switch case statement.

  • Identify the base definition needed for the question.
  • Apply the relevant rule or formula to the given values.
  • Trace each step with the given input.

Control statements and decisions. Control statements determine the order in which statements execute. Sequential execution runs statements one after another, selection chooses among alternatives, and repetition executes a block several times. The if statement executes a block only when a condition is true, and an else branch handles the false case. Nested if else structures refine a decision inside a chosen branch. The switch statement selects a case from an integer or character expression and is readable when many values lead to distinct actions. A break statement is needed after each case to prevent fall through into the next case. Relational and logical operators build the conditions used by these statements. Prime number checking uses a loop that tests possible divisors and a flag that records whether any divisor was found. A vowel or consonant check uses a switch or a chain of comparisons. An even or odd test can use the remainder operator or a switch on the remainder. A flowchart expresses the same decisions with a diamond for each test and arrows for the true and false paths. A good answer explains the statement forms, gives one complete program, traces it with a sample input and notes the common mistake of forgetting braces or break. Mentioning that well chosen conditions and clear indentation make logic easier to verify shows practical programming discipline. A short note that nested decisions should be kept shallow prevents unreadable code.

Result: State the traced result from the given data.

Tip from Examiner: State the concept, show the C code or flowchart with clear comments, trace one sample input, and mention the common mistake or boundary condition an examiner will look for.
Key Formula / Principle: $O(1)$ $\&$ $a\& b, a|b, a^b$

Key Points

  • Control Statements
  • A data type fixes the set of legal values and operations, su
  • Arithmetic, relational, logical, and bitwise operators have
  • Selection statements use conditions; iteration statements re
  • Functions accept parameters, return values, and reduce dupli
  • State the traced result from the given data.
Q4b7MUnit 1 — operators (arithmetic, relational, logical)
Survival ModePredictedRepeated

What do you mean by operator precedence and associativity in C? Explain with suitable example.

Concept / Given Data:

Operator precedence determines the order in which operators of different types are evaluated in an expression. Operator associativity determines the order of evaluation when operators of the same precedence appear together (left-to-right or right-to-left). Together they define the exact evaluation sequence the C compiler follows.

Key Principle: Higher-precedence operators bind tighter; for equal precedence, associativity (L→R or R→L) decides grouping. The full ladder is: Unary>Multiplicative (×,÷,%)>Additive (+,−)>Relational>Equality>&&>∣∣>Assignment>Comma\text{Unary} > \text{Multiplicative } (\times, \div, \%) > \text{Additive } (+, -) > \text{Relational} > \text{Equality} > \&\& > || > \text{Assignment} > \text{Comma}

Step-by-Step Explanation with Examples:

Step 1 — Precedence Example (different operators):

Consider the expression:

a=5+3×2a = 5 + 3 \times 2

Multiplication (×\times) has higher precedence than addition (++), so the compiler groups it as:

a=5+(3×2)=5+6=11a = 5 + (3 \times 2) = 5 + 6 = 11

If we wanted addition first, we must use explicit parentheses: (5+3)×2=16(5+3)\times 2 = 16.

Step 2 — Associativity Example (same precedence, L→R):

Consider:

b=100/10/5b = 100 / 10 / 5

Both divisions have the same precedence and are left-associative, so:

b=(100/10)/5=10/5=2b = (100 / 10) / 5 = 10 / 5 = 2

If it were right-associative (it is not), the result would be 100/(10/5)=10100 / (10/5) = 10.

Step 3 — Right-associative Example (assignment):

Consider:

c=d=7c = d = 7

Assignment is right-associative, so it evaluates as:

c=(d=7)c = (d = 7)

First dd receives 77, then cc receives the value of the assignment expression, which is 77. Both cc and dd equal 77.

Step 4 — Mixed Precedence + Associativity:

e=2+3×4−6/2e = 2 + 3 \times 4 - 6 / 2

Apply precedence: ×\times and ÷\div first (left-to-right among themselves):

e=2+12−3e = 2 + 12 - 3

Then ++ and −- (left-to-right):

e=(2+12)−3=14−3=11e = (2 + 12) - 3 = 14 - 3 = 11

Precedence & Associativity Table:

Precedence Level Operators Associativity
1 (highest) !, ~, ++, --, (type) Right → Left
2 *, /, % Left → Right
3 +, - Left → Right
4 <, <=, >, >= Left → Right
5 ==, != Left → Right
6 && Left → Right
7 || Left → Right
8 =, +=, -= Right → Left
9 (lowest) , Left → Right

Result: Precedence resolves which operator acts first; associativity resolves direction among equals. Always use parentheses to make intent explicit and avoid ambiguity in exam answers.

Tip from Examiner: In 7-mark PYQs (2023-24, 2024-25, 2025-26), examiners award 2 marks for the definition, 3 marks for a correct worked example showing grouping, and 2 marks for the table or a second example. Common mistake: writing $100/10/5 = 100/(10/5) = 10$ — this violates left-associativity and loses 3 marks. Always write the intermediate grouping in parentheses before computing the final value.

Key Points

  • Precedence = order among different operators; Associativity = direction among same-precedence operators
  • Multiplicative (*, /, %) > Additive (+, -) > Relational > Equality > && > || > Assignment > Comma
  • Assignment and unary operators are right-associative; all others are left-associative
  • Example: 100/10/5 = (100/10)/5 = 2 (L-to-R), NOT 100/(10/5) = 10
  • Always use explicit parentheses to override default precedence in exam answers
Q5a7MUnit 2 — Loops — for
Survival ModePredictedRepeated

Write a program to print the following pattern in C:



** *

1. Definition and scope: C programs use declarations, expressions, control statements and functions to solve the stated problem.

2. Scored mechanism:

  • Identify the declared types and values before applying the operator.
  • Apply C precedence and associativity when an expression has several operators.
  • Match the format specifier or file mode to the data being handled.
  • Arithmetic, relational and logical operators follow fixed precedence and associativity.
  • Selection and iteration statements control the order of execution.
  • Functions and arrays organise reusable logic and related data.

3. Marking points — Loops for:

C feature Purpose Example
Declaration reserves typed storage int a;
Control chooses or repeats actions if / for
Function packages reusable work return a+b;

4. Governing relation: Evaluate the given expression or statement using the declared types and C operator rules.

5. Application to the asked question: Write a program to print the following pattern in C: **** *** ** *

  • Write the relevant C statement or expression.
  • Trace it with the supplied values.
  • State the resulting value or output.

Loops in C. A loop repeats a block of statements while a condition remains true. The for loop places initialisation, condition and update together in one header, which suits situations where the number of iterations is known. The while loop tests the condition before each iteration, so the body may run zero times. The do while loop tests after the body, so it runs at least once. Every loop needs an update that moves the condition toward false, otherwise it never terminates. The break statement exits the nearest loop immediately, while continue skips the rest of the current iteration and proceeds to the next one. Nested loops are used for patterns and tables: the outer loop controls rows and the inner loop controls columns. For a descending star pattern, the number of stars decreases each row, so the inner limit depends on the row counter. Loop analysis also leads to time complexity. A loop that halves its input each time is logarithmic, a single pass is linear, and nested passes over the same data are quadratic. A good answer declares the loop variables, explains each header part, traces a short example and states the output. It should mention the risk of an off by one error, because starting at zero or stopping at the wrong bound changes the printed values. Mentioning that break can simplify a search once the item is found gives a practical use.

Result: Give the computed value or output for the stated program.

Tip from Examiner: State the concept, show the C code or flowchart with clear comments, trace one sample input, and mention the common mistake or boundary condition an examiner will look for.
Key Formula / Principle: $O(1)$ $\&$ $a\& b, a|b, a^b$

Key Points

  • Loops — for
  • Identify the declared types and values before applying the operator.
  • Apply C precedence and associativity when an expression has several operators.
  • Match the format specifier or file mode to the data being handled.
  • State the traced result from the given data.
  • Give the computed value or output for the stated program.
Q5b7MUnit 3 — Structures
Core Concept

Create a structure in C language for keeping the records of the employees of an organization about their Name, Designation, Salary, Department and City of posting. Write program to enter records of 100 employees and display the names of those with salary more than 20,000.

1. Definition and scope: C constructs provide the vocabulary for representing data and controlling execution: declarations define storage, operators transform values, and control statements choose the path of computation.

2. Scored mechanism:

  • A data type fixes the set of legal values and operations, such as int, float, char, string, or list.
  • Arithmetic, relational, logical, and bitwise operators have distinct precedence and associativity.
  • Selection statements use conditions; iteration statements repeat a block until a termination condition is met.
  • Functions accept parameters, return values, and reduce duplication through modular decomposition.
  • Recursion solves a problem by calling itself on a smaller instance with a clear base case.
  • Arrays store homogeneous elements in contiguous memory addressable by an index; Python lists are dynamic.

3. Marking points — Structures:

Construct Purpose Example
Sequence execute in order assignments
Selection choose a branch if / else
Iteration repeat a block for / while
Function reuse logic def / return

4. Procedure:

  1. Identify the base definition needed for the question.
  2. Apply the relevant rule or formula to the given values.
  3. Trace each step with the given input.
  4. State the final value.

5. Application to the asked question: Create a structure in C language for keeping the records of the employees of an organization about their Name, Designation, Salary, Department and City of posting. Write program to enter records of 100 employees and display the names of tho

  • Identify the base definition needed for the question.
  • Apply the relevant rule or formula to the given values.
  • Trace each step with the given input.

Structures, unions and linked data. A structure is a user defined type that groups related members which may have different types. It is declared with a tag and variables of that type can be created individually or as an array. Members are accessed with the dot operator, or with the arrow operator when working through a pointer. An array of structures is useful for records such as students or employees, where each element holds a name, designation, salary, department and city. A program can scan such an array and print only records whose salary exceeds a chosen limit. A union resembles a structure but all members share the same memory, so only one member can hold a valid value at a time. It saves space when alternatives are exclusive, for example storing different kinds of student information in one record. A self referential structure contains a pointer to another structure of the same type, which is the basis of a linked list. Each node holds data and a link to the next node, and a head pointer identifies the start. A good answer defines each term, gives a declaration, explains member access and shows a small traversal. It should state the difference between structure and union in terms of memory allocation and valid members. Mentioning that dynamic allocation allows a linked list to grow during execution connects the idea to practical programming.

Result: State the traced result from the given data.

Tip from Examiner: State the concept, show the C code or flowchart with clear comments, trace one sample input, and mention the common mistake or boundary condition an examiner will look for.
Key Formula / Principle: $O(1)$ $\&$ $a\& b, a|b, a^b$

Key Points

  • Structures
  • A data type fixes the set of legal values and operations, su
  • Arithmetic, relational, logical, and bitwise operators have
  • Selection statements use conditions; iteration statements re
  • Functions accept parameters, return values, and reduce dupli
  • State the traced result from the given data.
Q6a7MUnit 2 — Recursion — factorial and Fibonacci (simple examples only) Real connect: Control flow is the brain of every program — from traffic signal logic to drone autopilot decision-making
Core Concept

What is recursion? Write a program to find factorial of n numbers using recursion.

1. Definition and scope: C constructs provide the vocabulary for representing data and controlling execution: declarations define storage, operators transform values, and control statements choose the path of computation.

2. Scored mechanism:

  • A data type fixes the set of legal values and operations, such as int, float, char, string, or list.
  • Arithmetic, relational, logical, and bitwise operators have distinct precedence and associativity.
  • Selection statements use conditions; iteration statements repeat a block until a termination condition is met.
  • Functions accept parameters, return values, and reduce duplication through modular decomposition.
  • Recursion solves a problem by calling itself on a smaller instance with a clear base case.
  • Arrays store homogeneous elements in contiguous memory addressable by an index; Python lists are dynamic.

3. Marking points — Recursion factorial and Fibonacci simple:

Construct Purpose Example
Sequence execute in order assignments
Selection choose a branch if / else
Iteration repeat a block for / while
Function reuse logic def / return

4. Procedure:

  1. Identify the base definition needed for the question.
  2. Apply the relevant rule or formula to the given values.
  3. Trace each step with the given input.
  4. State the final value.

5. Application to the asked question: What is recursion? Write a program to find factorial of n numbers using recursion.

  • Identify the base definition needed for the question.
  • Apply the relevant rule or formula to the given values.
  • Trace each step with the given input.

Recursion and base cases. Recursion occurs when a function calls itself to solve a smaller instance of the same problem. It is useful when a problem is naturally defined in terms of a simpler version of itself, such as factorial, Fibonacci numbers or processing digits. Every recursive function needs two parts. The base case gives a direct answer for the smallest input and stops the chain of calls. The recursive case expresses the answer in terms of a call with a reduced input, so the problem moves toward the base case. Without a reachable base case, calls continue until the call stack is exhausted. Each call has its own local variables and return address stored on the stack, so recursion uses more memory than an equivalent loop. Factorial of zero or one is the base value one, and factorial of a larger number is that number multiplied by the factorial of the previous number. Fibonacci numbers use two base values and sum the two previous terms. A recursive digit product multiplies the last digit by the product of the remaining digits. A good answer defines recursion, identifies the base and recursive cases in the given program, traces a small input and explains the output. It should also state that recursion often gives shorter, clearer code but may be slower because of function call overhead. Mentioning that iteration can avoid stack growth shows a balanced understanding of the tradeoff.

Result: State the traced result from the given data.

Tip from Examiner: State the concept, show the C code or flowchart with clear comments, trace one sample input, and mention the common mistake or boundary condition an examiner will look for.
Key Formula / Principle: $O(1)$ $\&$ $a\& b, a|b, a^b$

Key Points

  • Recursion — factorial and Fibonacci (simple examples only) Real connect: Control flow is the brain of every program — from traffic signal logic to drone autopilot decision-making
  • A data type fixes the set of legal values and operations, su
  • Arithmetic, relational, logical, and bitwise operators have
  • Selection statements use conditions; iteration statements re
  • Functions accept parameters, return values, and reduce dupli
  • State the traced result from the given data.
Q7b7MUnit 3 — File Handling Real connect: Arrays store sensor readings
Core Concept

List out various file operations and modes in C. Write a C program to copy the content from one file to another file.

1. Definition and scope: C constructs provide the vocabulary for representing data and controlling execution: declarations define storage, operators transform values, and control statements choose the path of computation.

2. Scored mechanism:

  • A data type fixes the set of legal values and operations, such as int, float, char, string, or list.
  • Arithmetic, relational, logical, and bitwise operators have distinct precedence and associativity.
  • Selection statements use conditions; iteration statements repeat a block until a termination condition is met.
  • Functions accept parameters, return values, and reduce duplication through modular decomposition.
  • Recursion solves a problem by calling itself on a smaller instance with a clear base case.
  • Arrays store homogeneous elements in contiguous memory addressable by an index; Python lists are dynamic.

3. Marking points — File Handling Real connect Arrays:

Construct Purpose Example
Sequence execute in order assignments
Selection choose a branch if / else
Iteration repeat a block for / while
Function reuse logic def / return

4. Procedure:

  1. Identify the base definition needed for the question.
  2. Apply the relevant rule or formula to the given values.
  3. Trace each step with the given input.
  4. State the final value.

5. Application to the asked question: List out various file operations and modes in C. Write a C program to copy the content from one file to another file.

  • Identify the base definition needed for the question.
  • Apply the relevant rule or formula to the given values.
  • Trace each step with the given input.

File handling in C. A file is a named collection of data stored on a device. C treats a file as a stream of bytes and uses a file pointer of type FILE to manage it. Before reading or writing, the file must be opened with a mode that states the intended operation. Read mode opens an existing file for input, write mode creates a new file or empties an existing one, append mode adds at the end, and update modes allow both reading and writing. Text mode translates line endings, while binary mode preserves bytes exactly. Functions such as fgetc and fputc handle one character, fgets and fputs handle lines, and fprintf and fscanf handle formatted data. The feof function reports that a previous read tried to move past the end, so it should be checked after a read rather than used as the loop condition alone. A file used for input or output must be closed with fclose so buffers are flushed and resources are released. Common tasks include copying one file to another, counting vowels in a text file and displaying file contents. A good answer defines a file, lists the opening modes, explains at least three functions and gives a loop that reads until end of file. It should mention error handling, because a failed open returns a null pointer. A note that buffered input output improves speed explains why closing the file matters.

Result: State the traced result from the given data.

Tip from Examiner: State the concept, show the C code or flowchart with clear comments, trace one sample input, and mention the common mistake or boundary condition an examiner will look for.
Key Formula / Principle: $O(1)$ $\&$ $a\& b, a|b, a^b$

Key Points

  • File Handling Real connect: Arrays store sensor readings
  • A data type fixes the set of legal values and operations, su
  • Arithmetic, relational, logical, and bitwise operators have
  • Selection statements use conditions; iteration statements re
  • Functions accept parameters, return values, and reduce dupli
  • State the traced result from the given data.