Model Question Paper- I
First/ Second Semester B.E Degree Examination, 2025-26
Introduction to C Programming (1BPLC105E/205E)
TIME: 03 Hours [Link]
Notes:
1. Answer any FIVE full questions, choosing at least ONE question from each MODULE
2. M: Marks, L: Bloom’s level, C: Course outcomes.
Module -1 M L C
Q.01 a Define algorithm. Outline an algorithm to convert temperature from Fahrenheit 8 L2 CO1
to Celsius.
b Define functions. Explain basic structure of a C Program. 5 L2 CO1
c Explain Input and Output functions in C Programming with suitable example 7 L2 CO1
OR
Q.02 a Explain the role of flow chart in program development. List the symbols used 8 L2 CO1
in designing a flowchart. Illustrate with one example.
b List the features of C programming language. Explain the process of compiling 5 L2 CO1
and executing a C Program.
c Define Identifier. List the rules for framing an identifier with an example to 7 L2 CO1
each rule.
Module-2
Q. 03 a Explain the following operators 8 L2 CO1
i) Increment and Decrement operators.
ii) Logical Operators
i) Increment and Decrement Operators
Increment (++) and Decrement (--) are unary operators (they
work on one variable).
Increment Operator (++)
• Increases the value of a variable by 1.
• Equivalent to:
• a = a + 1;
Decrement Operator (--)
• Decreases the value of a variable by 1.
• Equivalent to:
• a = a - 1;
Model Question Paper- I
Types of Increment / Decrement
There are two forms:
Post Increment / Post Decrement
Syntax: a++ or a--
First uses the value, then changes it.
Example:
int a = 5;
int b;
b = a++; // Post increment
What happens:
• b = 5 (original value of a is used)
• a becomes 6 (after assignment)
So,
b=5
a=6
Pre Increment / Pre Decrement
Syntax: ++a or --a
First changes the value, then uses it.
Example:
int a = 5;
int b;
b = ++a; // Pre increment
What happens:
• a becomes 6
• b=6
So,
b=6
a=6
Model Question Paper- I
Difference Between Pre and Post
Operator Action Order
a++ Use value → Then increment
++a Increment → Then use value
a-- Use value → Then decrement
--a Decrement → Then use value
ii) Logical Operators (Easy Explanation)
Logical operators are used to combine conditions (usually in if
statements).
They return:
• 1 (True)
• 0 (False)
1. Logical AND (&&)
Returns true (1) only if both conditions are true.
Syntax:
condition1 && condition2
Example:
int a = 10, b = 5;
(a > 5 && b > 2)
• a > 5 → True (1)
• b > 2 → True (1)
Result → 1 (True)
If any one condition is false → Result is 0.
AND Truth Table
A B A && B
1 1 1
1 0 0
0 1 0
0 0 0
Model Question Paper- I
Important:
If first condition is false, second condition is not checked.
2. Logical OR (||)
Returns true (1) if at least one condition is true.
Syntax:
condition1 || condition2
Example:
(a > 5 || b > 10)
• a > 5 → True
• So result → True (second condition not checked)
OR Truth Table
A B A || B
1 1 1
1 0 1
0 1 1
0 0 0
Important:
If first condition is true, second condition is not checked.
3. Logical NOT (!)
Reverses the result.
• True becomes False
• False becomes True
Example:
int a = 10, b = 5;
!(a > b)
• a > b → True (1)
• !(1) → 0 (False)
Model Question Paper- I
NOT Truth Table
A !A
1 0
0 1
Remaining Operators
✅ Operators (Simple Explanation)
🔹 What is an Operator?
An operator is a symbol used to perform an operation on values.
Example:
5+3
+ is the operator.
5 and 3 are operands.
1️⃣ Arithmetic Operators
Used to do mathematical calculations.
Operator Meaning Example
+ Addition 5+3=8
- Subtraction 5-3=2
* Multiplication 5 * 3 = 15
/ Division 10 / 2 = 5
% Remainder 10 % 3 = 1
Important:
• If both numbers are integers, result is integer.
• Example: 11 / 5 = 2
2️⃣ Relational Operators
Used to compare two values.
They give result:
• 1 → True
• 0 → False
Model Question Paper- I
Operator Meaning
< Less than
> Greater than
<= Less than or equal
>= Greater than or equal
== Equal to
!= Not equal
Example:
10 > 5 → 1 (True)
3 > 5 → 0 (False)
3️⃣ Assignment Operator
Used to store value in a variable.
Symbol:
=
Example:
a = 10;
b = a;
Now b = 10.
Important:
• Left side must be a variable.
• 10 = a ❌ Wrong
4️⃣ Conditional Operator (?:)
Also called ternary operator.
Symbols:
?:
Syntax:
condition ? value1 : value2;
Meaning:
• If condition is true → value1
• If condition is false → value2
Example:
large = (a > b) ? a : b;
Model Question Paper- I
It finds the largest number.
5️⃣ Bitwise Operators
Used to work with binary numbers (bits).
Operator Meaning
& Bitwise AND
` `
^ XOR
~ NOT
<< Left shift
>> Right shift
These are mostly used in advanced programming.
6️⃣ Special Operators
Some special operators are:
• sizeof → Finds size of variable
• & → Finds address of variable
• , → Separate expressions
7️⃣ Precedence of Arithmetic Operators
Order of solving:
1. ()
2. *, /, %
3. +, -
Example:
10 + 5 * 2 = 20
(Multiplication happens first)
b Explain the else if ladder with syntax and a suitable program. 6 L2 CO2
Else–If Ladder (Simple Explanation)
An else–if ladder is used when we have multiple conditions to check.
Model Question Paper- I
It is like asking questions one by one:
If first condition is true → execute it and stop
If not, check second condition
If not, check third condition
If none are true → execute else part
Real-Life Example
Imagine marks grading:
If marks ≥ 90 → Grade A
Else if marks ≥ 75 → Grade B
Else if marks ≥ 50 → Grade C
Else → Fail
The program checks from top to bottom.
Once one condition is true, it stops checking further.
🔹 Syntax (C Language)
if (condition1)
{
statement1;
}
else if (condition2)
{
statement2;
}
Model Question Paper- I
else if (condition3)
{
statement3;
}
else
{
statement4;
}
Example Program (Greatest of 3 Numbers)
#include <stdio.h>
Void main()
{
int a, b, c;
printf("Enter three numbers: ");
scanf("%d %d %d", &a, &b, &c);
if (a > b && a > c)
{
printf("a is greatest");
}
else if (b > a && b > c)
{
printf("b is greatest");
}
else
{
printf("c is greatest");
}
}
Model Question Paper- I
Remaining conditional statement
if Statement
The if statement is used to execute a block of code only if the condition
is true.
Syntax:
if (condition)
{
statements;
}
Working:
• If condition is true (1) → statements execute
• If condition is false (0) → statements are skipped
Example:
#include <stdio.h>
Void main()
{
int a = 10;
if (a > 5)
{
printf("a is greater than 5");
}
}
Model Question Paper- I
Output:
a is greater than 5
Because condition is true.
if – else Statement
Used when we want to execute one block if condition is true
and another block if condition is false.
Syntax:
if (condition)
{
statements1;
}
else
{
statements2;
}
Working:
• If condition is true → first block runs
• If condition is false → else block runs
Example:
#include <stdio.h>
Void main()
{
int a = 3;
if (a > 5)
{
printf("a is greater than 5");
}
else
{
printf("a is not greater than 5");
Model Question Paper- I
}
}
Output:
a is not greater than 5
Nested if – else
Nested means if inside another if.
Used when we check multiple conditions.
Syntax:
if (condition1)
{
if (condition2)
{
statements;
}
else
{
statements;
}
}
else
{
statements;
}
Example: Largest of 3 Numbers
#include <stdio.h>
Void main()
{
int a = 4, b = 2, c = 5;
if (a > b)
{
if (a > c)
Model Question Paper- I
printf("a is largest");
else
printf("c is largest");
}
else
{
if (b > c)
printf("b is largest");
else
printf("c is largest");
}
}
Output:
c is largest
c Outline the syntax of switch statement. Given an integer between 1 to 7 6 L3 CO2
representing the day of week, develop a program to display day in
words using switch statement [E.g. for a number 1, print Sunday and
for number 7, print
Saturday](Note :In this Program carries 5 marks)
Switch Case Statement
The if-else statement allows selection between two options.
But sometimes we need to choose one among many options.
For this, C provides multi-way decision making statements, such as:
• if-else ladder
• switch case statement
Why Switch Case?
In an if-else ladder, the program checks multiple conditions one by one.
This may reduce performance when there are many conditions.
To avoid multiple condition checking, C provides the switch case
statement.
Model Question Paper- I
Syntax of Switch Case
switch (expression)
{
case value1:
statement1;
statement2;
break;
case value2:
statement1;
statement2;
break;
case value3:
statement1;
statement2;
break;
default:
statement1;
statement2;
break;
}
next statement;
PROGRAM(Very IMP)
#include <stdio.h>
#include <conio.h>
void main()
{
int day;
clrscr();
Model Question Paper- I
printf("Enter a number (1-7): ");
scanf("%d", &day);
switch(day)
{
case 1:
printf("Sunday");
break;
case 2:
printf("Monday");
break;
case 3:
printf("Tuesday");
break;
case 4:
printf("Wednesday");
break;
case 5:
printf("Thursday");
break;
case 6:
printf("Friday");
break;
case 7:
printf("Saturday");
break;
default:
printf("Invalid input! Please enter number between 1 and 7.");
Model Question Paper- I
}
getch();
OR
Q.04 a Show the evaluation order of the following expression with intermediate and 8 L2 CO1
final values: 100/20<=10-5+100%10-20==5>=1!=20
Priority Operators
1 /, %
2 +, -
3 <, <=, >, >=
4 ==, !=
Step-by-Step Evaluation
Step 1: Division and Modulus (/, %)
100 / 20 = 5
100 % 10 = 0
Now expression becomes:
5 <= 10 - 5 + 0 - 20 == 5 >= 1 != 20
Step 2: Addition and Subtraction (+, -)
Evaluate left to right:
10 - 5 = 5
5+0=5
5 - 20 = -15
Now expression becomes:
5 <= -15 == 5 >= 1 != 20
Step 3: Relational Operators (<=, >=)
Evaluate left to right:
5 <= -15 → 0 (False)
5 >= 1 → 1 (True)
Now expression becomes:
0 == 1 != 20
Model Question Paper- I
Step 4: Equality Operators (==, !=)
Evaluate left to right:
0 == 1 → 0
0 != 20 → 1
Final Answer
1 (True)
Final Result
The value of the expression is:
1
To Remember
Priority Operators Associativity
1 (Highest) () Left to Right
2 ++, --, !, ~, + (unary), - (unary), sizeof Right to Left
3 *, /, % Left to Right
4 +, - Left to Right
5 <, <=, >, >= Left to Right
6 ==, != Left to Right
7 & (Bitwise AND) Left to Right
8 ^ (Bitwise XOR) Left to Right
9 ` ` (Bitwise OR)
10 && (Logical AND) Left to Right
11 `
12 ?: (Conditional operator) Right to Left
13 =, +=, -=, *=, /=, %= Right to Left
14 (Lowest) , (Comma operator) Left to Right
Model Question Paper- I
b Differentiate between entry controlled loop and exit controlled loop. 6 L2 CO2
1. Entry Controlled Loop (While loop)
2. Exit Controlled Loop (Do-While loop)
Entry Controlled Loop (While loop)
• The computer checks the condition first.
• If the condition is false, it will not run even once.
• Used when the loop may not need to run.
Syntax:
while ( test condition )
{
statement-1;
statement-2;
}
Example
int i = 1;
while(i <= 3)
{
printf("%d ", i);
i++;
}
Output:
123
If i = 5, nothing will print because the condition is false.
Exit Controlled Loop (Do-While loop)
• The computer runs the loop first, then checks the condition.
• It always runs at least once, even if the condition is false.
• Used when the loop must run at least one time.
Syntax:
do {
statement-1;
Model Question Paper- I
statement-2;
statement-n;
} while ( test condition );
Example
int i = 5;
do
{
printf("%d ", i);
i++;
} while(i <= 3);
Output:
5
Even though the condition is false, the loop ran once.
Difference Between While and Do-While Loops
Feature While Loop Do-While Loop
Condition Checked Before running After running
Runs Minimum 0 times 1 time
Use When loop may not run When loop must run at least once
Keyword while do...while
Example Input until correct Show menu at least once
STUDY THIS ALSO
For Loop in C
The for loop is a type of entry-controlled loop.
It is used when we know how many times we want to repeat a block
of code.
Parts of a For Loop
A for loop has 3 parts inside the parentheses:
for (initialization; condition; increment/decrement)
1. Initialization
o Sets the starting value of the loop variable.
o Executed only once at the beginning.
Model Question Paper- I
2. Condition
o Checked before each iteration.
o If true → loop runs.
o If false → loop stops.
3. Increment / Decrement
o Updates the loop variable after each iteration.
o Can increase (a++) or decrease (a--).
Syntax
for(initialization; condition; increment/decrement)
{
// statements to repeat
}
• Statements inside { } are called loop body.
• After finishing the loop body, the loop goes back and checks the
condition again.
Example Program
#include <stdio.h>
#include <conio.h>
void main()
{
int a;
clrscr();
// For loop from 1 to 5
for(a = 1; a <= 5; a++)
{
printf("a: %d\n", a);
}
getch();
}
Model Question Paper- I
c Develop a C program to find the sum of first n numbers using while 6 L3 CO2
loop.
#include <stdio.h>
#include <conio.h>
void main()
{
int n, i = 1, sum = 0;
clrscr();
// Input from user
printf("Enter a positive number: ");
scanf("%d", &n);
// While loop to calculate sum
while(i <= n)
{
sum = sum + i; // Add current number to sum
i++; // Increment i by 1
}
// Display result
printf("Sum of first %d numbers is: %d\n", n, sum);
getch();
}
IMP arithmetic operation program usin switch
#include <stdio.h>
#include <conio.h>
void main()
{
int a, b, result;
char symbol;
Model Question Paper- I
clrscr();
// Input numbers
printf("Enter first number: ");
scanf("%d", &a);
printf("Enter second number: ");
scanf("%d", &b);
// Input operator
printf("Enter an operator (+, -, *, /, %%): ");
scanf(" %c", &symbol);
// Perform operation and print immediately
switch(symbol)
{
case '+':
result = a + b;
printf("Result: %d + %d = %d\n", a, b, result);
break;
case '-':
result = a - b;
printf("Result: %d - %d = %d\n", a, b, result);
break;
case '*':
result = a * b;
printf("Result: %d * %d = %d\n", a, b, result);
break;
case '/':
result = a / b;
printf("Result: %d / %d = %d\n", a, b, result);
Model Question Paper- I
break;
case '%':
result = a % b;
printf("Result: %d %% %d = %d\n", a, b, result);
break;
default:
printf("Invalid operator!\n");
}
getch();
}
Module-3
Q. 05 a Define string. Develop a program to read a string, reverse the string and print. 6 L3 CO3
b Define array. List and explain the types of arrays. 6 L2 CO3
c Develop a program to multiply two N*N matrices. 8 L3 CO3
OR
Q. 06 a Develop a program to find the length of a string without using built in 6 L3 CO3
function.
b Explain declaring and initialization one, and two-dimensional arrays with 6 L2 CO3
suitable examples.
c Develop a program to read N numbers and find the sum and average of N 8 L3 CO3
numbers using an array.
Module-4
Q. 07 a Define function in C. Justify the need of user defined functions in C with a 8 L2 CO4
suitable program.
b Explain with example “No arguments and no return values” of functions. 6 L2 CO4
c Develop a C program to perform arithmetic operations (+, -, /, *) using user 6 L3 CO4
defined functions.
OR
Q. 08 a List and Explain the various elements of user defined functions. 8 L2 CO4
b What is nested function? Explain with example. 6 L2 CO4
c Develop a suitable program having a function with arguments and no return 6 L3 CO4
value.
Module-5
Q. 09 a Define structure. Explain the general format of a structure definition. 6 L2 CO5
b Define pointer. Illustrate declaring and initialization of a pointer variable. 6 L2 CO5
c Define a structure type student that would contain student name, 3 subject 8 L3 CO5
marks Using this structure, Develop a C program to read four students data
from keyboard and print the same on the screen.
OR
Q. 10 a Differentiate between arrays and structures with an example. 6 L2 CO5
b Illustrate with suitable code for swapping of two numbers using pointers. 6 L2 CO5
c Develop a program to copy and compare of structure variables. 8 L3 CO5