click anywhere on this page Download App
Model Answers_Unit 01_December 2024 Question Paper_FPL
______________________________________________________________________________
Q1. a) Define an algorithm and write an algorithm for addition of two numbers [3]
Definition of Algorithm: An algorithm is a step-by-step procedure or a finite set of instructions
used to solve a problem or perform a specific task.
Algorithm for Addition of Two Numbers:
1. Start
2. Declare three variables: num1, num2, and sum
3. Read the values of num1 and num2
4. Calculate sum = num1 + num2
5. Display the value of sum
6. Stop
______________________________________________________________________________
Q1. b) Explain brief history of ‘C’ programming [3]
Brief History of C Programming:
1. The C programming language was developed in 1972 by Dennis Ritchie at Bell
Laboratories.
2. It was created to develop the UNIX operating system and was designed to be a powerful,
flexible language.
3. C evolved from earlier languages like BCPL and B, incorporating features of both while
introducing better data types and control structures.
4. In 1978, Brian Kernighan and Dennis Ritchie published "The C Programming Language",
also known as K&R C, which became the standard reference.
5. Later, in 1989, ANSI (American National Standards Institute) approved a standard version
called ANSI C, improving portability and consistency.
Click here join Telegram channel
6. C has greatly influenced many modern languages like C++, Java, and Python.
______________________________________________________________________________
Q1. c) Define an identifier in C. Explain rules of naming an identifier. [4]
Definition of Identifier: An identifier in C is the name used to identify variables, functions,
arrays, and other user-defined elements. It is created by the programmer and helps in uniquely
naming program elements.
Rules for Naming an Identifier in C:
1. Only alphabets (A–Z, a–z), digits (0–9), and underscore (_) are allowed.
Example: total_marks, sum1
2. The first character must be an alphabet or underscore (_), not a digit.
Valid: _count, value1
Invalid: 1value
3. C is case-sensitive, so Total and total are treated as different identifiers.
4. No spaces or special symbols (like @, #, !, etc.) are allowed.
5. Keywords (like int, float, if, while) cannot be used as identifiers.
6. Length of an identifier should ideally be meaningful and manageable. ANSI C supports at
least the first 31 characters as significant.
Example:
______________________________________________________________________________
Click here join Telegram channel
Q1. d) Explain data types in C. [4]
Explanation of Data Types in C:
Data types in C define the type of data a variable can store. They help the compiler allocate
memory and interpret data correctly.
C has the following main categories of data types:
1. Primary (Basic) Data Types:
Data Type Description Example
int Stores integer values int age = 20;
float Stores decimal numbers float temp = 36.5;
char Stores single characters char grade = 'A';
double Stores large decimal numbers double pi = 3.14159;
2. Derived Data Types:
Type Description Example
Array Collection of similar data types int marks[5];
Pointer Stores address of another variable int *ptr;
Structure Group of variables of different types struct student { ... };
Union Similar to structure but shares memory union data { ... };
Function A block of code for reuse int sum(int a, int b);
Click here join Telegram channel
3. Enumeration Data Type
Type Description Example
enum User-defined type with fixed set of constants enum week { Mon, Tue, Wed };
4. Void Data Type
Type Description Example
void Represents absence of data type void display();
Note:
C also supports data type modifiers such as short, long, signed, and unsigned to modify the size
and range of basic data types.
______________________________________________________________________
Q2. a) Draw a flowchart for division of two numbers. [3]
Description:
The flowchart takes two numbers as input and performs division, then displays the result.
Flowchart Symbols Used
1. Terminator (Oval): Start/End
2. Input/Output (Parallelogram): For reading or displaying values
3. Process (Rectangle): For performing operations
Note:
Ensure that num2 is not zero to avoid division-by-zero errors in practical implementation.
Click here join Telegram channel
Flowchart:
______________________________________________________________________________
Q2. b) Explain tokens in C programming. [3]
Definition:
Tokens are the smallest units in a C program that are meaningful to the compiler. The compiler
breaks the program into these individual units during the compilation process.
Click here join Telegram channel
Types of Tokens in C:
Token Type Description Example
Keywords Reserved words with special meaning in C int, return, if
Identifiers Names used for variables, functions, arrays, etc. sum, main, count
Fixed values that do not change during program
Constants execution 10, 'A', 3.14
Operators Symbols used to perform operations +, -, *, /, ==
Special
Symbols Symbols with special purposes in syntax ;, {}, (), []
"Hello", "C
Strings Sequence of characters enclosed in double quotes Language"
Example Code Snippet:
Here, tokens are:
int
sum
10
20
______________________________________________________________________________
Click here join Telegram channel
Q2. c) Explain different storage classes in C. [4]
Storage classes in C define the scope (visibility), lifetime, and default initial value of variables.
They help the compiler determine how and where to store variables.
C provides four storage classes:
Storage
Class Keyword Scope Lifetime Default Value Example Use
Local to the
Automatic auto block Till block exists Garbage value Local variables
Global (outside Till program
External extern file) ends Zero Sharing across files
Local to the Till program Preserve local
Static static block ends Zero values
Local to the Fast-access
Register register block Till block exists Garbage value variables
Descriptions:
1. auto:
Default for local variables.
Not needed explicitly.
2. extern:
Used to declare a global variable defined in another file.
Click here join Telegram channel
3. static:
Retains its value between function calls.
4. register:
Suggests storing variable in CPU register for fast access.
______________________________________________________________________________
Q2. d) Define a constant in C. What are the different types of constants in C? [4]
A constant in C is a fixed value that does not change during the execution of a program.
Constants are used to represent unchanging data such as numbers, characters, or strings.
Types of Constants in C:
1. Integer Constants
Whole numbers without any fractional part.
Can be decimal, octal, or hexadecimal.
Examples: 10, 077 (octal), 0x1A (hexadecimal)
2. Floating-Point Constants
Numbers with a decimal point or written in exponential form.
Examples: 3.14, -0.005, 2.5e3
Click here join Telegram channel
3. Character Constants
A single character enclosed in single quotes.
Represented using ASCII values internally.
Example: 'A', '9', '%'
4. String Constants
A sequence of characters enclosed in double quotes.
Always ends with a null character (\0).
Example: "Hello", "123"
5. Symbolic Constants
Defined using the #define preprocessor directive.
Used to assign names to constant values.
Note: Constants improve code readability, maintenance, and help avoid accidental changes to
critical values.
______________________________________________________________________________
★★★★★★★★★★★★
Click here join Telegram channel
Model Answers_Unit 02_December 2024 Question Paper_FPL
______________________________________________________________________________
Q3. a) Define an operator and operand in C programming. Give a suitable example. [3]
Operator: An operator in C is a symbol that tells the compiler to perform a specific
mathematical, logical, or relational operation.
Operand: An operand is the data (variable or value) on which the operator performs the
operation.
Example:
+ is the operator (Addition)
a and b are operands
Explanation:
In the above example, the + operator adds the values of operands a and b, and the result is stored
in the variable sum.
______________________________________________________________________________
Q3. b) What is a conditional operator in C? Explain with a suitable example. [3]
The conditional operator is also known as the ternary operator because it takes three
operands. It is used to evaluate a condition and return one of two values based on whether the
condition is true or false.
Syntax:
If the condition is true, the result is expression1.
If the condition is false, the result is expression2.
Click here join Telegram channel
Example:
Output:
Here, (a > b) is the condition.
If true, max = a; else, max = b.
Output:
Since a is not greater than b, max = 20.
Use:
The conditional operator provides a compact alternative to if...else statements for simple
decisions.
Click here join Telegram channel
______________________________________________________________________________
Q3. c) Explain relational operators in ‘C’. [4]
Relational operators are used to compare two values or expressions. The result of a relational
operation is either true (1) or false (0). These operators are mainly used in decision-making and
looping statements.
List of Relational Operators:
Operator Description Example Result
== Equal to a == b True if a is equal to b
!= Not equal to a != b True if a is not equal to b
> Greater than a>b True if a is greater than b
< Less than a<b True if a is less than b
>= Greater than or equal to a >= b True if a is greater than or equal to b
<= Less than or equal to a <= b True if a is less than or equal to b
Example:
Click here join Telegram channel
Click here join Telegram channel
Output:
Use: Relational operators are essential for conditional statements like if, while, and for to control
the flow of a program based on comparisons.
______________________________________________________________________________
Q3. d) What is the use of assignment operators? Explain different assignment operators. [4]
Use of Assignment Operators:
Assignment operators in C are used to assign values to variables. These operators store the
value of an expression in a variable. They are commonly used in all types of C programs to
update or initialize variable values.
Types of Assignment Operators in C:
Operator Description Example Equivalent To
= Assign right-hand value to left-hand variable a = 10; —
+= Add and assign a += 5; a = a + 5;
-= Subtract and assign a -= 3; a = a - 3;
*= Multiply and assign a *= 2; a = a * 2;
/= Divide and assign a /= 4; a = a / 4;
%= Modulus and assign a %= 3; a = a % 3;
Click here join Telegram channel
Example Code:
Click here join Telegram channel
Output:
Conclusion: Assignment operators help to write shorter and more efficient code. They are
widely used in loops, calculations, and logic-based operations.
______________________________________________________________________________
Q4. a) Explain different arithmetic operators with suitable example. [3]
Arithmetic operators are used to perform basic mathematical operations such as addition,
subtraction, multiplication, division, and modulus.
Types of Arithmetic Operators:
Operator Operation Example Description
+ Addition a+b Adds two numbers
- Subtraction a-b Subtracts second number from first
* Multiplication a * b Multiplies two numbers
/ Division a/b Divides first number by second
% Modulus a%b Finds remainder after division
Click here join Telegram channel
Example:
Output:
These operators are essential for performing calculations and are widely used in mathematical
and logical operations in C programming.
______________________________________________________________________________
Click here join Telegram channel
Q4. b) What are the different logical operators in “C” [3]
Logical operators are used to combine two or more conditions and return a result in terms of
True (1) or False (0). They are mostly used in decision-making statements like if, while, and for.
Click here join Telegram channel
Output:
Conclusion: Logical operators are essential for decision-making in C programs, especially
inside control structures like if, while, and for loops.
______________________________________________________________________________
Q4. c) Explain bitwise operators in ‘C’. [4]
Operator Name Description
& Bitwise AND Sets each bit to 1 if both bits are 1
| Bitwise OR Sets each bit to 1 if one of the two bits is 1
^ Bitwise XOR Sets each bit to 1 if only one of the bits is 1
~ Bitwise NOT Inverts all the bits
<< Left Shift Shifts bits to the left
>> Right Shift Shifts bits to the right
Click here join Telegram channel
Output:
______________________________________________________________________________
Q4. d) What do you mean by operator precedence? Specify the precedence of arithmetic
operators? [4]
Operator precedence determines the order in which different operators are evaluated in an
expression when there are multiple operators. Operators with higher precedence are evaluated
before operators with lower precedence.
If operators have equal precedence, associativity (either left-to-right or right-to-left) is used to
determine the order of evaluation.
Precedence of Arithmetic Operators in C:
Precedence Level Operators Description Associativity
Highest */% Multiplication, Division, Modulus Left to Right
Lower + - Addition, Subtraction Left to Right
Click here join Telegram channel
Output:
______________________________________________________________________________
★★★★★★★★★★★
Click here join Telegram channel
Model Answers_Unit 03_December 2024 Question Paper_FPL
Q5. a) Explain different conditional / branching statements in C programming [4]
In C programming, branching or conditional statements are used to alter the flow of execution
based on certain conditions. They help in decision-making during program execution.
Types of Branching/Conditional Statements:
Statement
Type Description Syntax Example
1. if Executes a block of code if a specified
Statement condition is true. if (a > b) { printf("a is greater"); }
2. if-else Executes one block if the condition is true,
Statement another block if it is false. if (a > b) { printf("a"); } else { printf("b"); }
3. else-if Checks multiple conditions in sequence.
Ladder Executes the block of the first true condition. if (a > b) {...} else if (a == b) {...} else {...}
An if statement inside another if block. Used
4. Nested if for complex conditions. if (a > 0) { if (b > 0) { ... } }
5. switch Used to select one of many code blocks to
Statement execute based on the value of a variable. switch (choice) { case 1: ...; break; ... }
if Statement
Output:
Click here join Telegram channel
if-else Statement
Output:
else-if Ladder
Output:
Click here join Telegram channel
Nested if Statement
Output:
switch Statement
Output:
______________________________________________________________________________
Click here join Telegram channel
Q5. b) Explain the while loop with syntax, flowchart and give a suitable example. [5]
The while loop in C is an entry-controlled loop, which means the condition is evaluated before
the execution of loop statements. If the condition is true, the block of code inside the loop is
executed repeatedly until the condition becomes false.
Syntax:
Flowchart:
Condition: A logical expression evaluated before each iteration.
If the condition is true, the loop body runs.
If the condition is false, the loop exits.
Example: Print numbers from 1 to 5
Click here join Telegram channel
Output:
______________________________________________________________________________
Q5. c) Write a program in C to find the factorial of a number. [5]
Output:
______________________________________________________________________________
Click here join Telegram channel
Q6. a) Explain use of break and continue statements in C programming with a suitable
example. [4]
Example: break statement
Output:
Example: continue statement
Output:
Click here join Telegram channel
______________________________________________________________________________
Q6. b) Explain for loop with syntax, flowchart and give a suitable example. [5]
The for loop in C is a pre-tested loop that allows repeating a block of code a specific number of
times. It is commonly used when the number of iterations is known in advance.
Syntax of for Loop:
Flowchart:
Initialization: Sets the starting value (runs once).
Condition: Evaluated before every iteration; loop runs if true.
Increment/Decrement: Updates loop variable after each iteration.
Click here join Telegram channel
Example: for statement
Output:
______________________________________________________________________________
Q6. c) Write a C program to check whether a number is even or odd. [5]
Output:
______________________________________________________________________________
★★★★★★★★
Click here join Telegram channel
Model Answers_Unit 04_December 2024 Question Paper_FPL
Q7. a) Explain one dimensional array with a suitable example. [4]
A one-dimensional array in C is a collection of elements of the same data type stored in
contiguous memory locations. Each element in the array can be accessed using its index,
starting from 0.
Syntax:
Example:
Output:
______________________________________________________________________________
Click here join Telegram channel
Q7. b) What are the different ways of initialization of arrays in C programming? [5]
In C programming, arrays can be initialized in various ways. Initialization means assigning
values to the elements of the array at the time of declaration.
1. Complete Initialization at Declaration: All elements are initialized at once.
2. Partial Initialization: Only some elements are initialized; the rest are set to zero by default.
3. Initialization without Specifying Size: If the size is not mentioned, the compiler
automatically sets it based on the number of values.
4. Element-wise Initialization: Each element can be assigned separately.
5. Designated Initializers (C99 Standard and above): You can specify values for specific
indices.
Array initialization methods provide flexibility depending on the program’s requirements. Proper
initialization avoids garbage values and helps in efficient data processing.
______________________________________________________________________________
Click here join Telegram channel
Q7. c) Write a program in ‘C’ for addition of two matrices. [5]
Click here join Telegram channel
Output:
______________________________________________________________________________
Q8. a) What are the properties of arrays in C? [4]
Arrays in C have the following key properties:
1. Homogeneous Elements: An array can store only elements of the same data type (e.g., all int
or all float).
2. Contiguous Memory Allocation: Array elements are stored in
continuous memory locations, which allows for fast access using indexing.
3. Fixed Size: Once declared, the size of an array is fixed and cannot be changed during runtime.
4. Indexed Access:
Elements can be accessed directly using their index, starting from 0 to (size-1).
Example: arr[0] refers to the first element.
5. Static or Automatic Storage:
By default, arrays declared inside a function are automatically allocated on the stack unless
specified otherwise (e.g., using static).
6. Efficient Iteration:
Arrays support sequential processing using loops like for, while, etc., which makes them ideal
for repetitive data operations.
Click here join Telegram channel
Example:
Arrays are essential for handling collections of data in a structured and efficient manner in C
programming.
______________________________________________________________________________
Q8. b) What are the different ways of string initialization? [5]
In C programming, a string is an array of characters ending with a null character \0.
There are multiple ways to initialize strings in C:
1. String Literal Initialization:
Automatically appends \0 at the end.
Size is determined by the compiler (6 bytes in this case: 5 characters + 1 null terminator).
2. Character Array with Explicit Characters:
Manually includes the null character.
Useful when more control is needed over individual characters.
3. Character Array with Specified Size:
Click here join Telegram channel
Extra space is reserved in memory (here, 10 bytes).
Remaining elements are filled with \0 or garbage values depending on context.
4. Using Pointer to String Literal:
Points to a string literal stored in read-only memory.
Efficient, but modifying the string is not allowed (undefined behavior).
5. Input at Runtime Using scanf() or gets():
Allows runtime initialization.
Use fgets() instead of gets() for safety (to prevent buffer overflow).
Conclusion: String initialization can be done using literals, arrays, or pointers. Choosing the
right method depends on whether the string needs to be modified, the memory size, and runtime
behavior.
______________________________________________________________________________
Click here join Telegram channel
Q8. c) Write a C program to count the number of strings in a string using a looping statement.
[5]
Output:
______________________________________________________________________________
★★★★★★★★★★★★★
Click here join Telegram channel
Model Answers_Unit 05_December 2024 Question Paper_FPL
Q9. a) Explain user defined function definition with syntax and give a suitable example. [4]
A user-defined function in C is a function created by the programmer to perform a specific task.
It helps in modular programming, code reusability, and improves program readability.
Syntax of a User-Defined Function:
Example: Program to calculate the square of a number using a user-defined function.
Output:
Conclusion: User-defined functions improve clarity and make debugging easier in large
programs.
______________________________________________________________________________
Click here join Telegram channel
Q9. b) What is a recursion? Explain it with a suitable example. [5]
Recursion is a programming technique where a function calls itself directly or indirectly to
solve a problem. Each recursive call works on a smaller sub-problem until a base condition is
met, which stops further calls.
Syntax:
Example: Factorial using Recursion
Output:
Advantages of Recursion:
Simplifies code for problems like factorial, Fibonacci, and tree traversal.
Reduces code size for repetitive problems.
______________________________________________________________________________
Click here join Telegram channel
Q9. c) Write a C program for leap year using a function. [5]
Output:
______________________________________________________________________________
Q10. a) Explain structure declaration and initialization. [4]
A structure in C is a user-defined data type that allows grouping of variables of different data
types under one name.
Syntax:
Click here join Telegram channel
Example:
Structure Variable Declaration:
Structure variables can be declared in two ways:
1. After the structure definition:
2. Along with the structure definition:
Structure Initialization:
You can initialize structure members at the time of declaration.
s1.roll_no = 101
[Link] = "Amit"
[Link] = 85.5
Click here join Telegram channel
Conclusion:
Structures in C are useful to handle related but different types of data as a single unit, especially
in programs like student records, employee data, etc.
______________________________________________________________________________
Q10. b) Explain function declaration, function definition and function call. Give a suitable
example. [5]
In C programming, a function is a block of code that performs a specific task.
It improves code modularity and reusability.
A function has three key parts:
1. Function Declaration (Prototype): It tells the compiler about the function name, return type,
and parameters.
Syntax:
Example:
2. Function Definition: This contains the actual code to be executed when the function is called.
Syntax:
Example:
Click here join Telegram channel
3. Function Call: This is how we execute the function from main() or another function.
Syntax:
Example:
Complete Example:
Output:
Conclusion: Functions in C enhance clarity, reduce code repetition, and make debugging easier.
Declaring, defining, and calling functions properly is essential for structured programming.
______________________________________________________________________________
Click here join Telegram channel
Q10. c) Write a C program for prime numbers using a function. [5]
Output:
______________________________________________________________________________
★★★★★★★★★★
Click here join Telegram channel