Second Year (12 Class) Computer Science Past Paper 2024


COMPUTER 2024


Max. Marks: 60Time: 3 Hours


SECTION "A" MULTIPLE CHOICE QUESTIONS (MCQs) Marks: 15


1 Choose the correct answer for each from the given options: Choose the correct answer for each from the given options:


1. This is a valid C expression:

  • int num = 100;
  • int num = ab 10;
  • int my num = 100;
  • Int num = 100;

2. In the context of while loop and do while loop in C, this is not true:

  • Both the loops are repetitive
  • Both will be executed at least one
  • Both loop has multiple executions
  • Both loop has unexpected conditions

3. The full form of IDE is:

  • integrated design environment
  • integrated development environment
  • internal design environment
  • interconnected design environment

4. This format specifier is used for integer data type:

  • % f
  • % c
  • % d
  • % If

5. Collection of related files is called:

  • Files
  • Database
  • Records
  • Reports

6. This is a primary object in Ms-Access:

  • Table
  • Form
  • Query
  • Report

7. One-to-many refers to:

  • Cardinality
  • Constraint
  • Join
  • Union

8. An object whose value can be changed during the program execution is called:

  • Symbol
  • Variable
  • Constant
  • Operator

9. A pictorial representation of program logic is called:

  • Flow chart
  • Procedure
  • Source code
  • Algorithm

10. Loop within the loop is called:

  • Nested loop
  • Infinite loop
  • Inner loop
  • Outer loop

11. The C preprocessor directives are specified with this symbol:

  • #
  • %
  • $
  • &

12. Every C program must contains:

  • At least one function
  • No function
  • Multiple functions
  • No value

13. In database, columns are called:

  • Field
  • Keys
  • File
  • Table

14. scanf() is predefined function in this header file:

  • stdio.h
  • stype.h
  • svalue.h
  • iostream

15. The format specifier % f is used for:

  • float
  • int
  • string
  • double

SECTION "B" (Short Answer Question) Marks: 30


NOTE: Attempt any TEN part questions in all. All part questions carry equal marks.
Answer should not exceed 6 to 7 lines.


2. i) What is meaning of two void in any function declaration? ie void ABC(void);

The first void specifies that the function does not return any value, meaning it performs a task without providing output.

The second void inside the parentheses indicates that the function does not take any arguments and requires no inputs when called.

Together, this defines a function, such as void ABC(void);, that takes no input and returns no value. It is commonly used for simple operations or actions in C programming.


ii. Differentiate between any one.

a) Source Code and Object Code

Aspect Source Code Object Code
Definition Human-readable instructions written by a programmer in a high-level language. Machine-readable code produced by a compiler.
Readability Easily understandable by humans. Not human-readable; consists of binary (0s and 1s).
Purpose To provide logical instructions for solving problems. To be directly executed by the computer's processor.
Language Type High-level programming languages (e.g., Python, Java). Low-level machine code.
Conversion Tool Written manually by programmers. Generated automatically by a compiler.
Usage Serves as input for compilers and debugging. Serves as output for execution by hardware.


b) Variable and Local Variable

Aspect Variable Local Variable
Definition A variable is a named storage location in memory used to store data, which can be accessed throughout the program depending on its scope. A local variable is a variable that is defined within a specific function or block and is accessible only within that scope.
Scope Can have global or local scope depending on where it is declared. Has a limited scope within the function or block where it is declared.
Usage Used to store data that might be needed in multiple parts of the program. Used for temporary storage and computations within a specific function or block.
Lifetime Exists for the entire runtime of the program if declared globally. Exists only while the function or block is executing.
Accessibility Global variables can be accessed anywhere in the program. Accessible only within the specific function or block where they are declared.

iii) What are pre-processor directives in C language? Name any two.

What are pre-processor directives in C language?

Pre-processor directives in C language are commands that give instructions to the compiler to process the source code before actual compilation begins. These directives typically begin with a # symbol and allow you to include files, define macros, or perform conditional compilation.

Two examples of pre-processor directives:

1. #include - Used to include the contents of another file, typically header files, into the program.

2. #define - Used to define macros or symbolic constants.


iv) Write a program to display the following output.

1 12 18
7 14 21
8 16 24

Program:

    
#include <stdio.h>

int main() {
    printf(" 1   12   18\n");
    printf(" 7   14   21\n");
    printf(" 8   16   24\n");
    return 0;
}

v) What will be the output of the C code.

main(){
    int a = 11;
    while(a <= 20)
    {printf("%d", a); a += 2;}
}

Output:
1113151719


vi) Convert the following, mathematical expression into C expression:


vii) Define any two input and output functions in C.

Two Input Functions:
1. scanf
   - Used to take input from the user.
   Example:
   int number;
   printf("Enter a number: ");
   scanf("%d", &number);

2. gets
   - Used to take a line of text input from the user.
   Example:
   char name[50];
   printf("Enter your name: ");
   gets(name);

Two Output Functions:
1. printf
   - Used to display values or text.
   Example:
   int age = 25;
   printf("You are %d years old", age);

2. puts
   - Used to display a string followed by a newline.
   Example:
   char message[] = "Hello, World!";
   puts(message);

viii) Differentiate between while loop and do while loop.

Aspect While Loop Do-While Loop
Definition A loop that executes the code block only if the condition is true. A loop that executes the code block at least once before checking the condition.
Condition Check Condition is checked before the loop body is executed. Condition is checked after the loop body is executed.
Execution Does not execute even once if the condition is false initially. Executes at least once, even if the condition is false initially.
Syntax
while(condition) {
  // code block
}
do {
  // code block
} while(condition);
Use Case Used when the condition must be validated before entering the loop. Used when the code block needs to be executed at least once regardless of the condition.


ix) What is the purpose of the main()function in any C program?

The purpose of the main() function in any C program is to serve as the entry point for program execution. When a C program runs, the execution starts with the main() function, making it mandatory in almost all C programs. It typically contains the primary logic and instructions that drive the program.



x) What is the function of "break" statement in C?

The break statement in C is used to exit or terminate a loop or a switch statement prematurely. When the break statement is encountered, it immediately stops the execution of the current loop or switch and transfers control to the code that follows outside of it.


xi What is a DBMS?

A DBMS (Database Management System) is software designed to manage and interact with databases. Its primary purpose is to enable users to create, retrieve, update, and manage data efficiently while ensuring data integrity, security, and consistency.


xii) Define primary key and foreign key.

A primary key is a unique identifier for each record in a database table. It ensures that no two rows in the table have the same value for the primary key column(s). Primary keys help maintain data integrity and make it easy to reference specific records.

A foreign key is a field in one table that refers to the primary key in another table. It establishes a relationship between two tables and ensures data consistency by linking them.


xiii) Write the full form of any three of the following acronyms:

  1. DML - Data Manipulation Language
  2. DDL - Data Definition Language
  3. SQL - Structured Query Language
  4. IDE - Integrated Development Environment
  5. RDBMS - Relational Database Management System

xiv) Write a program in C to check weather the entered number is even or odd:

    #include <stdio.h>

int main() {
    int number;
    printf("Enter a number: ");
    scanf("%d", &number);

    if (number % 2 == 0) {
        printf("%d is even.\n", number);
    } else {
        printf("%d is odd.\n", number);
    }

    return 0;
}
    

xv) What is the role of DBA in DBMS?


A Database Administrator (DBA) manages and maintains the database system, ensuring its performance, security, and reliability. They handle tasks like designing databases, monitoring their health, setting user permissions, backing up data, and recovering it when needed. Essentially, they ensure the database runs smoothly and supports organizational goals effectively.


Section C (Detailed -Answer Question) Marks: 30


NOTE: Attempt any three question from this section. All questions carry equal marks.


3. What is user-defined function? How is it differ from library function? Write any two with examples.

A user-defined function is a function created by the programmer to perform specific tasks in their program. It's tailored to meet unique requirements that might not be covered by pre-defined functions. These functions are defined using the syntax of the programming language, like Python's def keyword or C/C++'s function declaration.

On the other hand, a library function is a pre-written function provided by a programming language or framework. These functions are part of standard libraries and are designed to perform common tasks, like mathematical operations, string manipulations, or file handling.

Key Differences:

1. Origin:

- User-defined functions are written by the programmer.

- Library functions are built into the programming language or framework.

2. Purpose:

- User-defined functions are tailored to the specific needs of the program.

- Library functions are generic and meant for broader usage.

Examples:

User-defined Function:

In Python:

def greet(name):
    return f"Hello, {name}!"

print(greet("Syed"))  # Output: Hello, Syed!

Here, the function greet is created by the programmer.

Library Function:

In Python:

import math

result = math.sqrt(25)  # Output: 5.0
print(result)

Here, math.sqrt() is a library function provided by Python’s standard math library to calculate square roots.


4. What is relationship in database? Define three types of relationships in database with examples.

In a database, a relationship refers to the association or connection between two or more tables, based on common data. Relationships help organize and retrieve related information efficiently.

Types of Relationships:

1. One-to-One (1:1): Each record in Table A is linked to exactly one record in Table B, and vice versa.

Example: A table of employees and a table of employee ID cards where each employee has one unique ID card.

2. One-to-Many (1:N): Each record in Table A can be linked to multiple records in Table B, but each record in Table B is linked to one record in Table A.

Example: A table of customers and a table of orders, where each customer can place multiple orders.

3. Many-to-Many (M:N): Records in Table A can be linked to multiple records in Table B, and records in Table B can be linked to multiple records in Table A.

Example: A table of students and a table of courses, where each student can enroll in multiple courses, and each course can have multiple students. (This is often implemented using a junction table.)


5. Explain various types of database models.

A database model defines the structure, relationships, and operations for organizing and managing data within a database system. Here are the key types of database models:

1. Hierarchical Model

In the hierarchical model, data is organized in a tree-like structure. Each parent node can have multiple child nodes, but each child node has only one parent.

Example: A company database where the structure starts with the CEO, followed by managers, and then employees.

2. Relational Model

The relational model organizes data into tables (relations) with rows and columns. Relationships between tables are established through primary keys and foreign keys.

Example: An e-commerce database with `Customers` and `Orders` tables linked through a `CustomerID`.

3. Network Model

The network model represents data as a graph, with nodes and edges. It allows many-to-many relationships between entities and is more flexible than the hierarchical model.

Example: A transportation system where cities are connected by multiple routes.

4. Object-Oriented Model

In the object-oriented model, data is represented as objects, similar to objects in programming. Each object contains data and methods to manipulate it.

Example: A multimedia database where images and videos are stored as objects with their attributes like size, format, etc.

5. Entity-Relationship (ER) Model

The ER model uses diagrams to visually represent entities, attributes, and relationships within a database system. It is often used during database design.

Example: A student database showing relationships between `Students`, `Courses`, and `Professors` entities.

6. Document Model

The document model organizes data as documents, typically in JSON or XML format. It is widely used in NoSQL databases.

Example: A content management system storing articles in JSON format.

7. Key-Value Model

The key-value model stores data as key-value pairs. It is simple and efficient for scenarios where relationships between data are minimal.

Example: A cache system where product IDs are keys, and product details are values.

8. Column-Family Model

The column-family model organizes data into columns and column families, and is often used in distributed databases.

Example: A large-scale analytics database with user information stored in column families like demographics, behavior, etc.


6. What is control structure? Explain selection control structure.

A control structure is a fundamental concept in programming that determines the flow of execution of instructions in a program. It helps manage decision-making, looping, and branching in the code to achieve specific tasks or logic. Control structures are primarily categorized into three types: sequential, selection, and iteration.

Selection Control Structure

The selection control structure is used to make decisions based on a condition or set of conditions. It enables the program to select a specific block of code to execute based on whether a condition evaluates to true or false.

Types of selection control structures:

  • If Statement: Executes a block of code if the specified condition is true.
  • If-Else Statement: Executes one block of code if the condition is true, and another block of code if the condition is false.
  • Nested If: Allows multiple levels of conditions within an if or if-else statement.
  • Switch Statement: Allows execution of one block of code out of multiple options based on the value of an expression.

Example (If-Else):

The following pseudocode checks if a number is positive or negative:

if (number > 0) {
  print("The number is positive.");
} else {
  print("The number is negative.");
}

7. Explain all the data types in C language

Data types in C define the type of data that can be stored and manipulated in a program. They are categorized as follows:

1. Basic Data Types

  • int: Used to store integer values (e.g., 1, -5, 100).
  • float: Used to store decimal numbers (e.g., 1.23, -4.56).
  • double: Used for double-precision floating-point numbers for higher accuracy.
  • char: Used to store a single character (e.g., 'A', 'b').

2. Derived Data Types

  • Array: A collection of elements of the same data type stored sequentially in memory.
  • Pointer: A variable that stores the address of another variable.
  • Structure: A collection of variables of different data types grouped together.
  • Union: Similar to structures but uses a shared memory location for all its members.

3. Enumeration Data Type

  • enum: Used to define a set of named integral constants. For example:
      enum Color {RED, GREEN, BLUE};
      

4. Void Data Type

  • void: Represents the absence of a value. It is used for functions that do not return any value.

5. Type Modifiers

Type modifiers are used to modify the properties of basic data types, such as size and range. Examples include:

  • signed: Allows storing both positive and negative numbers.
  • unsigned: Allows storing only positive numbers, extending the range.
  • short: Reduces the size of the integer data type.
  • long: Increases the size of the integer or double data type.

Each data type plays a specific role in programming and is chosen based on the requirements of the program.

No comments:

Post a Comment