BPOPS103_CIE1(set2)_Scheme
BPOPS103_CIE1(set2)_Scheme
(Accredited by NAAC, Approved by A.I.C.T.E. New Delhi, Recognised by Govt. of Karnataka & Affiliated to V.T U., Belagavi)
#57, Chimney Hills, Hesaraghatta Main Road, Chikkabanavara Post, Bengaluru- 560090
CIE –1 (Set-1)
Certificate
I hereby certify that I have completed the specified syllabus for the CIE exam. I have referred to the
specified Text and reference books and additional books and notes. Questions are set to cover the Course
Outcomes and Bloom learning levels specified for the CIE.
Faculty HOD
Name: Sharath Babu & Mr. Vamsi Dr. Shankar
Signature:
CIE –1 (Set=2)
b What is a variable? What are the rules for constructing variables? Classify CO1 1
the following as valid/invalid Identifiers.
• num2
• $numl
• +add
• a2
• 199_space
• num2 - Valid
• $numl - Invalid
• +add - Invalid
• a2 - Valid
• 199_space - Invalid
c Write the flowchart and algorithm for the simple calculator. CO1 1
Algorithm:
Step 1: Start
Step 2: [Enter an operator]
Read operator
Step 3: [enter any two operands]
Read num1 and num2
Step 4: [compute the results as per user choice]
case '+':
result = num1 + num2;
goto step 6
case '-':
result = num1 - num2;
goto step 6
case ‘*':
result = num1 * num2;
goto step 6
case ‘/':
result = num1 / num2;
goto step 6
Step 7: Stop
FLOW CHART
User-Defined Functions
1. Created by the programmer to handle specific tasks.
2. Require the user to define their logic and structure.
3. No need for external libraries unless specified by the user.
4. Examples include custom functions like int add(int a, int b).
5. Flexibility to implement tailored solutions for program requirements.
6. Efficiency depends on the user's programming skills.
OR
2 a Explain primitive datatypes with a simple C program. CO1 1
Primitive data types are the basic building blocks of any program. They represent
simple types of data and can store values such as numbers, characters, and more.
In C, the primary primitive data types include:
1. Integer (int): Stores whole numbers.
2. Floating Point (float): Stores decimal numbers.
3. Double (double): Stores large floating-point numbers with double
precision.
4. Character (char): Stores single characters.
5. Void (void): Represents no value (used in functions)
#include <stdio.h>
int main()
{
// Primitive Data Types
int age = 20; // Integer
float height = 5.9; // Floating point
double pi = 3.141592653589; // Double
char grade = 'A'; // Character
// Displaying values
printf("Age: %d\n", age); // %d for int
printf("Height: %.1f feet\n", height); // %.1f for float
printf("Value of Pi: %.lf\n", pi); // %.lf for double
printf("Grade: %c\n", grade); // %c for char
return 0;
}
• Debugging Across Function Calls: Tracing errors that span across multiple
function calls can be challenging.
OR
Advantages Disadvantages
Code Reusability Complexity for smaller programs
Better memory utilization More memory usage
Takes less time to execute Takes more time to execute
Code length is minimized in case Increased size in code length
of calling the same functions
multiple times
Debugging is easy Debugging is bit difficult
3 a What are iterative statements? Explain three types of statements and their CO2 2
syntax.
Example:
b Briefly explain type conversion and type casting with a simple example. CO2 2
c Write a program to find the largest of 3 numbers using ternary operators CO2 2
CO3 3
d Write a C program to add two numbers using functions.
// Function to add two numbers
int add()
{
int x, y;
printf("Enter two numbers: ");
scanf("%d %d", &x, &y);
return x + y;
}
int main()
{
// Call the add function and store the result
int result = add();
// Print the result
printf("The sum is %d\n", result);
return 0;
}
OR
#include <stdio.h>
// Function to add two numbers
int add(int x, int y)
{
return x + y;
}
int main()
{
int a = 5, b = 3;
return 0;
}
OR
4 a Describe any 4 types of operators with examples. CO2 2
b Explain with syntax, if, and if-else statements in the C program. CO2 2
A:
B:
C:
d Write a C program to find whether the given number is odd or even using CO3 3
functions.
#include <stdio.h>
// Function to check whether the number is odd or even
void OddEven()
{
int num;
printf("Enter a number: ");
scanf("%d", &num);
if (num % 2 == 0)
{
printf("%d is Even\n", num);
}
else
{
printf("%d is Odd\n", num);
}
}
int main()
{
// Call the OddEven function
OddEven();
return 0;
}