Computer Science and Applications H.S. 1st year (solved paper)

 

Engaging study material for students – Exam-ready notes, guides, and resources to enhance learning and boost academic success.

Full Marks: 70
Time: 3 Hours


Section 1: Short Answer Questions

1. Answer the following questions:

a) What is meant by a package?

A package is a collection of related classes and interfaces in Java. It helps in organizing code, avoiding name conflicts, and improving maintainability.
Example: java.util is a package that contains utility classes like ArrayList and HashMap.

b) What is a character constant in C++?

A character constant in C++ is a single character enclosed in single quotes (' '). It has an integer equivalent called an ASCII value.
Example:

char ch = 'A';  // Character constant with ASCII value 65

c) What does program maintenance refer to?

Program maintenance refers to modifying and updating software after deployment. It includes bug fixes, performance enhancements, and adapting to new requirements.

d) Why is the size of character arrays declared one more than the largest string they can hold?

Character arrays in C++ must have an extra space to store the null terminator ('\0'), which marks the end of the string.
Example:

char str[6] = "Hello";  // Requires 6 bytes: 'H' 'e' 'l' 'l' 'o' '\0'

e) What are reference parameters?

A reference parameter in C++ allows a function to modify the actual argument passed to it. It avoids unnecessary copies of data.
Example:

void update(int &x) {
    x = 10;
}

f) What happens when two variables have the same identifier in nested scope?

When two variables have the same identifier in nested scopes, the inner variable hides the outer one within its scope.

g) Why is the argument type 'int' in all character-handling functions?

Character-handling functions use int to support EOF (-1) and accommodate larger character sets like Unicode.

h) What is the purpose of using the typedef command in C++?

The typedef command creates aliases for data types, improving readability.
Example:

typedef unsigned int uint;
uint age = 25;

Section 2: Medium Answer Questions

2. Answer any ten questions:

a) What is a distributed operating system?

A Distributed OS runs across multiple computers but appears as a single system. It enhances performance and reliability.

b) What does a disk defragmenter do?

A disk defragmenter rearranges fragmented data on a hard disk, improving access speed.

c) Convert the octal number 3674₈ to binary.

Step 1: Convert each octal digit to binary:

3 → 011  
6 → 110  
7 → 111  
4 → 100  

Binary Equivalent: 011110111100₂

d) Write briefly about Blu-ray Disc.

A Blu-ray Disc (BD) is a high-capacity optical disc used for HD movies and data storage, with a capacity of 25GB per layer.

e) Rewrite the following program removing errors:

#include

const int a = 5;

void main()

{

     a = 10;

     cout>>"The value of a is:"<<a

}



Solved:
#include <iostream>
using namespace std;

const int a = 5;
int main() {
    int b = 10;
    cout << "The value of a is: " << a;
    return 0;
}

f) Write the use of %= operator with an example.

The %= operator calculates the remainder and assigns it to a variable.

int a = 10;
a %= 3;  // a = a % 3 → 10 % 3 = 1

g) What does documentation refer to?

Documentation explains code functionality, making it easier to understand and maintain.

h) Why are logical errors harder to detect?

Logical errors don’t cause compilation failures but lead to incorrect results, making them harder to find.

i) What are testing and debugging in a program?

  • Testing: Running the program to check for errors.
  • Debugging: Finding and fixing errors.

j) Rewrite using if-else:

if (y < z)
    x = y;
else
    x = z;

k) In what two ways is the return statement useful in a function?

  1. Returning values: Sends a result back to the caller.
  2. Exiting a function early: Stops execution immediately.

l) Distinguish between isupper() and toupper().

Function Description
isupper() Checks if a character is uppercase
toupper() Converts a lowercase character to uppercase

m) Output of the given C++ program:

#include<iostream.h>

void main()

{

char a[2] [10]= {"highway", "corridors"}; 

cout << a[0] <<< endl; 

cout << a[1];

}

Ans:
highway
corridors

Section 3: Long Answer Questions

3. Answer any nine questions:

a) Explain three types of language processors.

  1. Assembler: Converts assembly language to machine code.
  2. Compiler: Translates high-level code to machine code.
  3. Interpreter: Executes code line-by-line.

b) Write three advantages of using UNICODE.

  1. Supports multiple languages.
  2. Provides a unique code for every character.
  3. Standardized encoding across platforms.

c) Write a C++ program to print ASCII of a character.

#include <iostream>
using namespace std;
int main() {
    char ch;
    cout << "Enter a character: ";
    cin >> ch;
    cout << "ASCII value: " << int(ch);
    return 0;
}

d) Discuss two forms of writing real constants.

  1. Fractional form: 3.14, 0.005
  2. Exponential form: 2.5e3 (which means 2.5 × 10³)

e) Difference between Type Casting and Automatic Type Conversion.

Feature Type Casting Automatic Conversion
Control Done manually           Done automatically
Example (float) x int a = 3.5; (truncated to 3)

Section 4: Advanced Questions

4. Answer any three questions:

a) What is a variable? Why is it called a symbolic variable?

A variable stores data in memory. It is called a symbolic variable because it represents values symbolically in a program.

b) Construct logical expressions for given conditions.

  1. height >= 150 && height < 165
  2. a % 2 != 0
  3. (fees >= 1000 && fees <= 2000) || otime == 5000
  4. isupper(chc)
  5. (x % 2 == 0) && (x < 100)

c) When is a default argument value used in a function?

A default argument is used when no explicit value is provided in a function call.

void greet(string name = "User") {
    cout << "Hello, " << name;
}

d) Write a function to find the sum of rows and columns in a 2D array.

void sumRowsCols(float arr[3][3]) {
    // Implementation here
}

e) What is a structure?

A structure groups related variables under one name.

struct Student {
    string name;
    int age;
};


Post a Comment

0 Comments