FYUG Even Semester Examination, 2024
COMPUTER SCIENCE
(2nd Semester)
SECTION-A
Answer any twenty questions. (1 mark each)
Question 1: What is high-level programming language? 1 Mark
A high-level programming language is a programmer-friendly language that uses human-readable English-like text and mathematical notations, abstraction layers, and structured syntax to isolate code logic from underlying computer hardware architectures.
Question 2: What is assembler? 1 Mark
An assembler is a specialized system language translator utility that processes low-level assembly language source text blocks and coverts them down directly into hardware-native executable binary instruction codes.
Question 3: Define source code. 1 Mark
Source code is the foundational human-readable set of program instructions text lines formulated using structural programming rules before execution processing steps run through logical compiling systems.
Question 4: What is debugging? 1 Mark
Debugging represents the analytical cyclical sequence of isolating execution bugs, tracking programmatic compilation or execution failures, evaluating state dumps, and fixing internal syntax or structural faults in logical code blocks.
Question 5: What is the output of the compilation process? 1 Mark
The output of a compilation stage corresponds to low-level targeted architecture-bound intermediate binary files, commonly resolved into machine relocatable object code module files matching a .obj or .o baseline suffix standard.
Question 6: Define algorithm. 1 Mark
An algorithm represents a well-defined, ordered, and finite series of non-ambiguous step-by-step procedures configured systematically to resolve a particular computing or data problem statement within limited constraints.
Question 7: Name some common symbols used in flowcharting. 1 Mark
Standard geometric shapes configured in graphical program flowchart maps include the Terminal Oval (Start/End), Parallelogram (Input/Output data transfers), Rectangle (Process/Calculation operations), and Diamond (Conditional Branch/Decision routes).
Question 8: What are the rules for designing a flowchart? 1 Mark
A flowchart map must possess an identifiable distinct entry terminal and exit stop terminal, and logical process pathways should clear downward or rightward without overlapping lines or leaving active internal logic nodes disconnected.
Question 9: Who developed the C programming language? 1 Mark
The C foundational systems language was originally researched, implemented, and specified by the computer scientist Dennis Ritchie throughout the early years of the 1970s decade at AT&T Bell Laboratories.
Question 10: What is the role of the compiler and linker in the execution of a C program? 1 Mark
The compiler evaluates high-level language source expressions text directly down into object blocks, whereas the companion linker aggregates separate runtime modules, object dependencies, and static math arrays into one standalone runnable system executable utility.
Question 11: What is token in C? 1 Mark
A token defines the smallest atomic foundational logical component recognized systematically by a C parsing framework analyzer, including characters categorized explicitly as keywords, active identifiers, explicit literals, or punctuation operators.
Question 12: What is keyword? 1 Mark
Keywords are dedicated system-level reserved core vocabulary identifiers pre-allocated globally inside an environment standard template that hold unique immutable functional definitions and cannot be re-mapped into custom user names.
Question 13: What is symbolic constant? 1 Mark
A symbolic constant is a custom name substituted consistently in a source project using a preprocessor macro keyword descriptor, fixing data values permanently before processing compiler execution traces start.
Question 14: What is literal? 1 Mark
Literals serve as unchangeable hard-coded baseline data data points declared explicitly across algorithmic operations, represented straight as raw numbers, character runes, or continuous text arrays.
Question 15: What is a variable and how is it declared? 1 Mark
A variable serves as a mapped pointer placeholder bound to a clear logical memory storage block context, specified structurally using its targeted technical classification rules followed straight by an assigned tracking reference handle.
Question 16: What is the purpose of decision-making in C programming? 1 Mark
Decision-making blocks direct functional program flow tracks toward specific isolated logical runtime branches based directly upon evaluating whether conditional relational operations resolve cleanly to true or false states.
Question 17: Write the syntax of the 'if-else' statement in C. 1 Mark
The standard operational format syntax layout maps out as:
if (conditional_expression) {
// Blocks executed if expression evaluates true
} else {
// Blocks executed if expression evaluates false
}
Question 18: What is 'break' statement in C? 1 Mark
The structural break statement causes processing loops or nested selection structures to stop completely, routing processing tracking points over to the statement that follows the aborted logic structure.
Question 19: Write the syntax of the 'for' statement in C. 1 Mark
The formal syntax representation is arranged explicitly according to this layout structure:
for (initialization; condition; increment/decrement) {
// Code instructions loop block body content
}
Question 20: What does the 'continue' statements do in a loop in C? 1 Mark
The continue command bypasses remaining lines inside an active repetition loop pass, routing execution logic forward to compile the next conditional validation checks or tracking counter updates.
Question 21: What is an array? 1 Mark
An array is an structured data configuration collection containing a pre-allocated index sequence of elements sharing a uniform data type class situated sequentially within physical storage addresses.
Question 22: What is the purpose of a 'return' statement in a function? 1 Mark
The return statement passes computed algorithmic results straight back to the outer execution context that initiated the function block, immediately popping off local operational stack configurations.
Question 23: What is function declaration? 1 Mark
A function declaration (or method prototype signature blueprint) communicates a module's external identifier name, specific structural return criteria type, and ordered parameter arrays to the parsing engine prior to system usage points.
Question 24: What is function call? 1 Mark
A function call activates an isolated block segment execution sequence by transferring current positional pointers straight into target procedures alongside necessary runtime parameter values.
Question 25: Define pointer. 1 Mark
A pointer maps out as a dedicated structural address variable intended to contain raw target hexadecimal memory reference addresses tracking separate variables, functions, or sequential allocation records.
SECTION-B
Answer any five questions. (2 marks each)
Question 26: Differentiate between compiler and interpreter. 2 Marks
A compiler processes an entire input source file in one continuous overarching pass, generating independent, architecture-bound object files. In contrast, an interpreter processes code line-by-line, parsing and executing each command immediately without saving compiled machine files to disk.
Question 27: Differentiate between high-level and machine-level programming languages. 2 Marks
High-level programming languages use an abstract, human-readable layout structure that relies on tools like compilers to work on different processors. Machine-level instructions consist of direct streams of binary 1s and 0s that run natively on target processor hardware without any transformation steps.
Question 28: What are the qualities of a good algorithm? 2 Marks
A robust algorithm must deliver unambiguous clarity, where each step maps cleanly to a single possible meaning. It should also be complete, highly efficient with limited resource footprints, and definitively reach an end within a finite number of structural cycles.
Question 34: What are standard library functions in C? Give examples. 2 Marks
Standard library functions are pre-compiled built-in system routines bundled directly with runtime installations to handle recurring computer logic, like string parsing, system file I/O operations, and mathematical calculations. Common examples include printf(), scanf(), and sqrt().
Question 35: How do you declare and initialize one-dimensional array? Give example. 2 Marks
A one-dimensional array uses an explicit data-type marker, a unique variable identifier, and a bracketed length dimension constraint. It is populated using values enclosed within brace wrappers. For example:
int marks[5] = {85, 90, 78, 92, 88};
SECTION-C
Answer any five questions. (8 marks each)
Question 28 (Duplicate Numbering in Paper): What is error in computer program? Explain different types of error with suitable examples. 8 Marks
An error in a computer program represents an internal structural fault, semantic logic breakdown, or processing violation that prevents the program from compiling cleanly or delivering correct results. Programming errors are broadly categorized into three distinct system classes:
- Syntax Errors: These occur when source text layouts violate formal formatting and lexical grammar rule constraints of the language. The compilation phase fails completely until these are corrected.
Example: Omit a terminating semi-colon marker:int x = 10 // Compilation failure: expected ';' before token
- Runtime Errors: These errors slip past compilation checks but trigger processing exceptions that crash the program while it runs, typically due to invalid operations or resource issues.
Example: Numeric division operations running against zero states:int a = 5; int b = 0; int result = a / b; // System crash exception
- Logical Errors: The source code runs without crashing but produces incorrect calculation output because the underlying algorithmic steps do not match the intended design logic.
Example: Using an addition symbol when a multiplication operation was required:int area = length + breadth; // Computes sum instead of area calculation
Question 29: Draw a flowchart to find the largest among two different numbers entered by the user. 8 Marks
The architectural mapping tracking comparative state logic handling checks execution paths to find which of two user inputs holds the greater numeric value. The structural execution order works like this:
- Start the program execution track.
- Read input values into variables
AandB. - Evaluate the conditional test expression: Is
A > B? - If the condition is true, follow the branch to print
A is largest. - If the condition is false, follow the branch to print
B is largest. - Terminate the program execution loop.
Question 30: What is an identifier? Write the basic rules for naming an identifier. 8 Marks
An identifier is a user-defined custom text string that labels structural program elements like variables, custom function blocks, structured user arrays, or custom execution labels inside source files.
When defining identifiers, programmers must adhere to the following naming rules to pass standard compiler structural validation checks:
- Identifiers can only consist of uppercase or lowercase alphabetical characters (
a-z,A-Z), numeric digits (0-9), and the underscore symbol (_). - The first character of an identifier must be an alphabet letter or an underscore symbol; it cannot begin with a number.
- C is strictly case-sensitive. For example, the identifier variable name
TotalSumdefines an entirely separate memory entity fromtotalsum. - Reserved programming keywords (such as
int,while,return, orfloat) cannot be used as custom identifier names. - No blank spaces, dashes, or special typographic punctuation markings (like
@,$,%) are allowed within an identifier name.
Question 31: Explain the difference between pre-increment and post-increment operators. 8 Marks
Both unary operations increase an integer variable's value by 1. However, they follow fundamentally different structural rules when evaluated inside larger assignment statements or expressions:
| Feature Constraint | Pre-Increment (++x) |
Post-Increment (x++) |
|---|---|---|
| Operation Order | Increments the value first, then evaluates the variable in the expression. | Evaluates the current value in the expression first, then increments the variable. |
| Value Assignment Example | If x = 5, y = ++x assigns 6 to y, and x becomes 6. |
If x = 5, y = x++ assigns 5 to y, and then x becomes 6. |
| Execution Priority | High priority; value updates occur before expression resolution step. | Delayed priority; value updates happen after the line's primary expression resolves. |
Question 32: What is 'nested if-else' statement in C? 8 Marks
A nested if-else control structure contains one or more secondary if-else condition blocks embedded inside an outer if or else execution pathway. This approach allows developers to chain complex, multi-layered decision checks sequentially when checking complex conditional states.
if (primary_condition) {
if (sub_condition_one) {
// Runs if primary_condition and sub_condition_one are true
} else {
// Runs if primary_condition is true but sub_condition_one is false
}
} else {
// Runs if primary_condition evaluates to false
}
Nesting is highly effective for filtering hierarchical categories, checking multi-layered system access levels, or systematically narrow down variable states across compound computational scenarios.
Question 33: Differentiate between 'while' and 'do-while' statements. 8 Marks
The foundational behavioral execution differences between these iteration statements are summarized below:
| Evaluation Parameter | The while Loop Structure |
The do-while Loop Structure |
|---|---|---|
| Loop Control Class | Entry-controlled structural loop type. | Exit-controlled structural loop type. |
| Condition Check Point | Evaluates the loop condition at the start, before running the loop body. | Evaluates the loop condition at the end, after the loop body runs. |
| Minimum Run Count | Zero executions if the primary condition evaluates to false initially. | Guaranteed to run at least once, even if the condition is false from the start. |
| Syntax Layout Standard | while (cond) { ... } (No terminating semicolon) |
do { ... } while (cond); (Requires terminating semicolon) |
Question 37: What is testing? Explain some common types of testing techniques used in the software development process. 8 Marks
Testing is the systematic process of executing a software application under controlled conditions to verify that its actual behavior matches the intended specifications, ensuring robustness, code coverage, and high quality.
Common testing techniques used throughout the modern software engineering lifecycle include:
- Unit Testing: Focuses on isolated verification of individual code modules, standalone functions, or single class implementations, usually managed directly by the development team.
- Integration Testing: Verifies that independently developed code modules, external libraries, and system interfaces communicate correctly when combined.
- System Testing: Evaluates the complete, fully integrated software package as a whole against the project's original functional requirements and technical specifications.
- Functional Testing (Black-Box): Validates programmatic output assertions against specific input values without examining the internal mechanics or source logic of the application.
- Structural Testing (White-Box): Analyzes internal code structures, checking conditional logic paths, execution statements, and exception handlers to maximize test coverage.
Question 38: Differentiate between algorithm and flowchart. Write an algorithm to find the area of a rectangle. 8 Marks
An algorithm is a step-by-step, text-based narrative that outlines programmatic problem-solving logic using formal, human-readable language. A flowchart is a visual diagram that maps out that same execution logic using standard geometric shapes and directional arrows.
Algorithm to calculate the area of a rectangle:
Step 1: Start the calculation process. Step 2: Declare floating-point storage variables: length, breadth, area. Step 3: Prompt the user to enter the rectangle's length and breadth values. Step 4: Read and store the user inputs into the 'length' and 'breadth' variables. Step 5: Compute the result using the formula: area = length * breadth. Step 6: Display the calculated 'area' value on the output monitor interface. Step 7: Terminate program execution.
Question 39: (a) What are the basic structures of a C program? 4 Marks
A standard C source file follows a structured, hierarchical layout that includes several key sections:
- Documentation Section: Contains comments (
/* ... */) detailing the module's purpose, author information, and creation date. - Link Preprocessor Section: Includes system headers (e.g.,
#include <stdio.h>) to import core library declarations and dependencies. - Definition / Global Declaration Section: Defines symbolic macro constants (using
#define) and declares global variables accessible across all functions. - Main Function Block: The mandatory entry point (
int main()) where the program begins execution. All primary logic starts here. - Subprogram / User-Defined Functions: Contains the structural definitions and implementation logic for custom functions used throughout the application.
Question 39: (b) Write a C program to calculate simple interest. 4 Marks
The source implementation code matches the standard formula: Interest = (Principal * Rate * Time) / 100.
#include <stdio.h>
int main() {
float principal, rate, time, simple_interest;
printf("Enter principal amount: ");
scanf("%f", &principal);
printf("Enter annual interest rate (in %%): ");
scanf("%f", &rate);
printf("Enter time duration (in years): ");
scanf("%f", &time);
simple_interest = (principal * rate * time) / 100.0;
printf("\n--- Calculation Results ---\n");
printf("Calculated Simple Interest = %.2f\n", simple_interest);
return 0;
}
Question 40: What are data types in C? Explain them with suitable examples. 8 Marks
Data types in C define the nature, storage capacity, and memory layout of the values stored in variables, telling the compiler how to interpret the underlying binary data. They are classified into several core categories:
- Primary / Primitive Data Types: Intrinsic built-in types that handle basic values natively.
int: Used for whole numbers (e.g.,int age = 21;). Typically allocates 2 or 4 bytes.float: Used for single-precision floating-point numbers (e.g.,float salary = 4500.50;). Allocates 4 bytes.char: Stores a single character character encoded in ASCII (e.g.,char grade = 'A';). Allocates 1 byte.
- Derived Data Types: Constructed by combining or modifying the primary primitive types.
- Arrays: Sequential collections of uniform data points (e.g.,
int scores[10];). - Pointers: Memory variables that store references to other memory addresses (e.g.,
int *ptr;).
- Arrays: Sequential collections of uniform data points (e.g.,
- User-Defined Data Types: Custom structures designed by the programmer to model complex data.
struct: Combines variables of different data types into a single, cohesive record.
Question 41: What is operator? Explain the various operators used in C programming. 8 Marks
An operator is a special symbolic token that tells the compiler to perform specific mathematical, logical, or relational transformations on variables and data inputs. C features a rich set of operators, categorized by function:
- Arithmetic Operators: Used to execute fundamental mathematical calculations. Examples include addition (
+), subtraction (-), multiplication (*), division (/), and the modulus operator (%) which returns remainders. - Relational Operators: Compare two values and return a boolean true (1) or false (0) state. These include equality checks (
==), inequality (!=), greater than (>), and less than (<). - Logical Operators: Used to combine multiple conditional expressions. These include logical AND (
&&), logical OR (||), and logical NOT (!). - Assignment Operators: Store values in target variables. This includes the basic assignment operator (
=) as well as shorthand compound variants like+=,-=, and*=. - Increment and Decrement Operators: Unary operators that increase (
++) or decrease (--) an integer value by 1.
Question 42: What is 'switch' statement in C? Write the syntax and illustrate with a suitable example. 8 Marks
The switch statement is a multi-way selection structure that tests an expression against a list of constant integer or character values. When a match is found, the statements associated with that specific case branch are executed sequentially.
Syntax Format:
switch (integer_expression) {
case constant_1:
// Statements executed for constant_1
break;
case constant_2:
// Statements executed for constant_2
break;
default:
// Default statements executed if no matches occur
}
Implementation Example:
#include
int main() {
int rating = 2;
switch(rating) {
case 1:
printf("Priority Level: High\n");
break;
case 2:
printf("Priority Level: Medium\n");
break;
default:
printf("Priority Level: Standard\n");
}
return 0;
}
Question 43: Explain the 'for' loop in C. Write a C program using 'for' loop to find sum of natural numbers 1 to n. 8 Marks
The for loop is a compact, entry-controlled iteration structure ideal for loops where the exact number of passes is known beforehand. It neatly groups initialization, condition testing, and tracking counter updates into a single line at the top of the loop structure.
Program to calculate the sum of natural numbers from 1 to n:
#include <stdio.h>
int main() {
int n, i;
int total_sum = 0;
printf("Enter positive upper integer limit (n): ");
scanf("%d", &n);
for (i = 1; i <= n; i++) {
total_sum = total_sum + i;
}
printf("The total sum of natural numbers from 1 to %d is: %d\n", n, total_sum);
return 0;
}
Question 44: Differentiate between function prototype and function definition. Write a C program to find the sum of two numbers using a function. 8 Marks
A function prototype is a forward declaration statement that tells the compiler about a function's name, return type, and parameter list before it is used, ending with a semicolon. A function definition contains the actual implementation and code block that executes when the function is called.
Program to calculate the sum of two numbers using a function:
#include <stdio.h>
// Function Prototype Declaration
int calculateSum(int num1, int num2);
int main() {
int a, b, result;
printf("Enter value for first integer: ");
scanf("%d", &a);
printf("Enter value for second integer: ");
scanf("%d", &b);
// Activating function via call pass assignment
result = calculateSum(a, b);
printf("Resulting sum calculated inside function module = %d\n", result);
return 0;
}
// Function Definition Block
int calculateSum(int num1, int num2) {
int computed_value;
computed_value = num1 + num2;
return computed_value; // Return result to caller stack
}
Question 45: What are the importances of function in C programming? What is recursion? Give suitable example to illustrate recursion. 8 Marks
Functions are vital building blocks in C programming that enable modularity, allowing large, complex projects to be broken down into manageable, independent steps. They promote code reusability, make debugging and maintenance easier, and improve readability by eliminating duplicate code blocks.
Recursion is a programming technique where a function calls itself, either directly or indirectly, to solve a problem by breaking it down into smaller, self-similar sub-problems.
A recursive function requires a definitive base case to stop execution; without it, the function would call itself indefinitely and crash the program due to a stack overflow error.
Example: Calculating Factorial using Recursion:
#include <stdio.h>
// Recursive function declaration
long int calculateFactorial(int number);
int main() {
int target_num = 5;
printf("Factorial calculation of %d is: %ld\n", target_num, calculateFactorial(target_num));
return 0;
}
long int calculateFactorial(int number) {
// Base Case constraint boundary check
if (number <= 1) {
return 1;
} else {
// Recursive Call pattern rule: n * (n-1)!
return (number * calculateFactorial(number - 1));
}
}
EXAM FOCUS ENHANCEMENTS & REVISION GUIDE
1. Presentation Strategy
- Keyword Highlighting: Underline critical structural keywords like
break,static, andvolatilein your descriptive answers. - Code Cleanliness: Always use proper indentation when writing code blocks during exams to ensure they are readable and clear to the examiner.
- Flowchart Accuracy: Use proper geometric symbols for flowcharts (ovals for terminals, diamonds for conditional splits).
2. Common Student Mistakes
- Missing Semicolons: Forgetting the terminating semicolon on lines within a
do-whilecondition block structure. - Confusing Operators: Accidentally using the assignment operator (
=) inside conditional statements when an equality check (==) is required. - Array Out of Bounds: Forgetting that C arrays use zero-based indexing, meaning an array defined as
int data[5]spans indices from0to4, not5.
3. Key Formula Reference List
- Simple Interest: Interest = (P * R * T) / 100
- Rectangle Area Equation: Area = Length * Breadth
- Recursive Factorial Base Rule: Factorial(n) = n * Factorial(n - 1) when n > 1
4. Frequently Asked Questions (FAQ)
Q: What is the main structural difference between local and global scope variables?
A: Local variables are declared inside a specific function block and can only be accessed within that block. Global variables are declared outside of all functions, making them accessible to any function throughout the entire source file from their declaration point onward.
Q: Why is the modulus operator (%) not used with floating-point data types in C?
A: The modulus operator requires integer operands because it calculates the remainder of integer division. For floating-point numbers, you should use standard library functions like fmod() from the math.h header.