Punjab PSEB SS Computer Science study materials
Punjab PSEB SS Computer Science study resources

Punjab PSEB SS Computer Science practice questions

One question at a time. Build your Punjab PSEB SS Computer Science understanding.

First 50 of 200 questions. Each one lists the choices, the correct answer, and an explanation. The checker at the top of this page saves progress in this browser when it is available.

Continue in the practice tool above to load more questions, 50 at a time.

Question 1Computer Science (subject content as per PSEB syllabus)

In the PSEB Class 12 Computer Science syllabus, which number system is used internally by a digital computer to represent and process data?

  1. Decimal
  2. Octal
  3. Binary Correct answer.
  4. Hexadecimal

Explanation

Digital circuits have two stable voltage states, so all data is stored and manipulated in binary using only the digits 0 and 1. Decimal, octal and hexadecimal are convenient notations for humans but are converted to binary before processing.

Question 2Computer Science (subject content as per PSEB syllabus)

What is the decimal value of the binary number 1011?

  1. 13
  2. 9
  3. 11 Correct answer.
  4. 15

Explanation

Expanding by place values gives 1×8 + 0×4 + 1×2 + 1×1 = 8 + 2 + 1 = 11. Each position corresponds to a power of two starting from 2^0 on the right.

Question 3Computer Science (subject content as per PSEB syllabus)

Which logic gate produces an output of 1 only when both of its inputs are 1?

  1. NOT gate
  2. AND gate Correct answer.
  3. XOR gate
  4. OR gate

Explanation

The AND gate implements logical multiplication, so its output is high only for the input combination 1,1. Every other combination yields 0.

Question 4Computer Science (subject content as per PSEB syllabus)

In C, which header file must be included to use the printf and scanf functions?

  1. <math.h>
  2. <stdio.h> Correct answer.
  3. <conio.h>
  4. <string.h>

Explanation

The standard input/output library declares printf, scanf and related functions, and it is included with the directive #include <stdio.h>. Without this header the compiler cannot match the function prototypes.

Question 5Computer Science (subject content as per PSEB syllabus)

Which of the following is a valid identifier in C?

  1. 2ndValue
  2. float
  3. my-var
  4. total_marks Correct answer.

Explanation

An identifier may contain letters, digits and the underscore, but it must begin with a letter or underscore and must not be a keyword. total_marks satisfies all these conditions.

Question 6Computer Science (subject content as per PSEB syllabus)

What does the acronym HTML stand for in the context of web page design?

  1. Home Tool Markup Language
  2. Hyperlink and Text Management Language
  3. High Text Machine Language
  4. Hyper Text Markup Language Correct answer.

Explanation

HTML is the Hyper Text Markup Language, a markup language that uses tags to describe the structure of a web document. It is not a programming language because it contains no control structures.

Question 7Computer Science (subject content as per PSEB syllabus)

In a relational database, which key uniquely identifies each row of a table?

  1. Alternate key
  2. Foreign key
  3. Primary key Correct answer.
  4. Candidate key

Explanation

The primary key is the chosen candidate key that uniquely identifies every tuple and cannot contain null values. A table can have only one primary key, though it may be composite.

Question 8Computer Science (subject content as per PSEB syllabus)

Which of the following is an example of system software rather than application software?

  1. An operating system Correct answer.
  2. A web browser
  3. A spreadsheet program
  4. A photo editor

Explanation

System software manages hardware and provides a platform for other programs, and the operating system is its central example. Application software, in contrast, performs user-oriented tasks.

Question 9Computer Science (subject content as per PSEB syllabus)

What is the decimal equivalent of the hexadecimal number 2A?

  1. 42 Correct answer.
  2. 36
  3. 44
  4. 26

Explanation

In hexadecimal, A represents 10, so 2A equals 2×16 + 10×1 = 32 + 10 = 42. Each hex digit is weighted by a power of sixteen.

Question 10Computer Science (subject content as per PSEB syllabus)

What is the two's complement representation of the decimal number -5 using 8 bits?

  1. 11111011 Correct answer.
  2. 10000101
  3. 11111010
  4. 00000101

Explanation

First write +5 as 00000101, then invert all bits to get 11111010, and finally add 1 to obtain 11111011. Two's complement is the standard way signed integers are stored.

Question 11Computer Science (subject content as per PSEB syllabus)

A student writes the C statement `int x = 7 / 2;`. What value is stored in x?

  1. 3.5
  2. 2
  3. 3 Correct answer.
  4. 4

Explanation

Both operands are integers, so integer division is performed and the fractional part is truncated toward zero, giving 3. To obtain 3.5 at least one operand must be floating point.

Question 12Computer Science (subject content as per PSEB syllabus)

What is the output of the following C loop? int i, s = 0; for (i = 1; i <= 4; i++) s = s + i; printf("%d", s);

  1. 10 Correct answer.
  2. 6
  3. 4
  4. 24

Explanation

The loop adds 1, 2, 3 and 4, giving 1+2+3+4 = 10. The condition i <= 4 keeps the loop running for exactly four iterations.

Question 13Computer Science (subject content as per PSEB syllabus)

Which SQL clause is used to filter rows that satisfy a specified condition in a SELECT statement?

  1. ORDER BY
  2. GROUP BY
  3. WHERE Correct answer.
  4. HAVING

Explanation

The WHERE clause applies a condition to individual rows before grouping, so only matching rows are returned. It is placed after the table name in the query.

Question 14Computer Science (subject content as per PSEB syllabus)

A relation R(A, B, C) has the functional dependencies A → B and B → C. Which normal form does R violate, given that A is the only candidate key?

  1. Third normal form Correct answer.
  2. Fourth normal form
  3. First normal form
  4. Second normal form

Explanation

The key is A, and the dependency B → C is a transitive dependency because B is a non-prime attribute determining another non-prime attribute. Third normal form forbids such transitive dependencies on non-prime attributes.

Question 15Computer Science (subject content as per PSEB syllabus)

Which tag is used in HTML to create a hyperlink to another web page?

  1. <a> Correct answer.
  2. <url>
  3. <href>
  4. <link>

Explanation

The anchor tag <a> with the href attribute creates a clickable hyperlink, as in <a href="page.html">. The href attribute holds the destination address.

Question 16Computer Science (subject content as per PSEB syllabus)

What is the binary representation of the decimal number 25?

  1. 10101
  2. 11010
  3. 10011
  4. 11001 Correct answer.

Explanation

Repeated division by 2 gives remainders 1,0,0,1,1 read upward, so 25 = 16 + 8 + 1 = 11001 in binary.

Question 17Computer Science (subject content as per PSEB syllabus)

Which of the following correctly declares an array of 10 integers in C?

  1. int a = 10;
  2. int a[10]; Correct answer.
  3. array int a[10];
  4. int a(10);

Explanation

The declaration int a[10]; reserves space for ten integer elements indexed from 0 to 9. The size in brackets must be a positive constant expression.

Question 18Computer Science (subject content as per PSEB syllabus)

What is the primary function of the ALU in a computer's CPU?

  1. Controlling the flow of data between devices
  2. Performing arithmetic and logical operations Correct answer.
  3. Converting high-level code into machine code
  4. Storing the program during execution

Explanation

The Arithmetic Logic Unit carries out operations such as addition, subtraction, comparison and Boolean logic on data held in registers. The control unit and memory handle sequencing and storage respectively.

Question 19Computer Science (subject content as per PSEB syllabus)

What is the result of the Boolean expression (A AND B) OR (NOT A AND B) when simplified?

  1. B Correct answer.
  2. A AND B
  3. A
  4. A OR B

Explanation

Factor out B to obtain B AND (A OR NOT A). Since A OR NOT A is always 1, the expression reduces to B. This is an application of the distributive and complement laws.

Question 20Computer Science (subject content as per PSEB syllabus)

In a C program, what does the statement `p = &x;` do, where p is a pointer and x is an int variable?

  1. Makes p an alias for the value of x
  2. Declares x as a pointer variable
  3. Stores the address of x in p Correct answer.
  4. Copies the value of x into p

Explanation

The address-of operator & yields the memory location of x, and that address is assigned to the pointer p. Dereferencing p later with *p accesses the value stored at that location.

Question 21Computer Science (subject content as per PSEB syllabus)

Which transmission mode allows data to travel in both directions but only one direction at a time?

  1. Full duplex
  2. Half duplex Correct answer.
  3. Simplex
  4. Multiplex

Explanation

In half-duplex mode both stations can transmit and receive, but not simultaneously, as with a walkie-talkie. Simplex allows only one direction and full duplex allows both at once.

Question 22Computer Science (subject content as per PSEB syllabus)

Consider the C code: int i = 0; while (i < 3) { printf("%d", i); i++; } What is printed?

  1. 0123
  2. 012 Correct answer.
  3. 0 1 2 with spaces
  4. 123

Explanation

The loop prints i before incrementing it, starting from 0, and stops when i reaches 3. The output is therefore the three characters 012 with no separators.

Question 23Computer Science (subject content as per PSEB syllabus)

A class C network 192.168.10.0 uses the subnet mask 255.255.255.192. How many usable host addresses are available in each subnet?

  1. 62 Correct answer.
  2. 64
  3. 126
  4. 30

Explanation

The mask 255.255.255.192 borrows two bits for subnetting, leaving six host bits, so each subnet has 2^6 = 64 addresses. Subtracting the network and broadcast addresses leaves 62 usable hosts.

Question 24Computer Science (subject content as per PSEB syllabus)

A student wants to compute 2 raised to the power 5 in C using the library function pow. Which expression is correct?

  1. pow(2^5)
  2. pow 2, 5
  3. pow(2, 5) Correct answer.
  4. pow(2; 5)

Explanation

pow takes two arguments separated by a comma and returns a double, so pow(2, 5) yields 32.0. The header math.h must be included for its declaration.

Question 25Computer Science (subject content as per PSEB syllabus)

In a relational schema, a table has a composite primary key (StudentID, CourseID) and also contains the attribute StudentName, which depends only on StudentID. Which normal form is violated and why?

  1. 1NF, because StudentName is a repeating group
  2. 3NF, because StudentName determines CourseID
  3. 2NF, because a non-key attribute depends on part of the composite key Correct answer.
  4. BCNF, because StudentID is not a superkey

Explanation

Second normal form requires every non-key attribute to depend on the whole primary key. StudentName depends on only StudentID, which is a proper subset of the composite key, so this is a partial dependency.

Question 26Computer Science (subject content as per PSEB syllabus)

In the PSEB Computer Science syllabus, which of the following is classified as application software?

  1. BIOS firmware
  2. Operating system
  3. Word processor Correct answer.
  4. Device driver

Explanation

Application software is designed to help the user perform specific tasks such as word processing, spreadsheets, or browsing. System software, including the operating system, device drivers, and BIOS firmware, manages hardware and provides a platform for applications.

Question 27Computer Science (subject content as per PSEB syllabus)

Which number system uses the base 8 and the digits 0 through 7?

  1. Octal Correct answer.
  2. Hexadecimal
  3. Binary
  4. Decimal

Explanation

The octal number system has base 8 and uses only the digits 0 to 7. Binary uses base 2, decimal uses base 10, and hexadecimal uses base 16 with digits 0–9 and letters A–F.

Question 28Computer Science (subject content as per PSEB syllabus)

Which logic gate produces a HIGH output only when all of its inputs are HIGH?

  1. AND gate Correct answer.
  2. OR gate
  3. XOR gate
  4. NOT gate

Explanation

An AND gate outputs 1 only when every input is 1; if any input is 0, the output is 0. This behaviour matches the logical conjunction operation.

Question 29Computer Science (subject content as per PSEB syllabus)

In a database table, which term describes a column or set of columns that uniquely identifies each row?

  1. Alternate key
  2. Primary key Correct answer.
  3. Foreign key
  4. Candidate key

Explanation

A primary key is the chosen candidate key that uniquely identifies each row and cannot contain NULL values. It enforces entity integrity in the relation.

Question 30Computer Science (subject content as per PSEB syllabus)

Which HTML tag is used to define an ordered list?

  1. <ul>
  2. <ol> Correct answer.
  3. <dl>
  4. <li>

Explanation

The <ol> tag creates an ordered list, which numbers its items automatically. The <li> tag defines each list item inside either an ordered or unordered list.

Question 31Computer Science (subject content as per PSEB syllabus)

Which protocol is primarily used to transfer web pages between a web server and a browser?

  1. SMTP
  2. SNMP
  3. HTTP Correct answer.
  4. FTP

Explanation

HTTP (HyperText Transfer Protocol) defines how web browsers request and receive web pages from web servers. It operates at the application layer of the TCP/IP model.

Question 32Computer Science (subject content as per PSEB syllabus)

In C, what is the value of the expression 5 % 2?

  1. 1 Correct answer.
  2. 2
  3. 2.5
  4. 0

Explanation

The modulus operator % returns the remainder after integer division. Since 5 divided by 2 gives quotient 2 and remainder 1, the result is 1.

Question 33Computer Science (subject content as per PSEB syllabus)

A relation is in second normal form (2NF) if it is in 1NF and which condition holds?

  1. Every non-prime attribute is fully functionally dependent on the primary key Correct answer.
  2. It has no transitive dependencies
  3. Every determinant is a candidate key
  4. It has no multivalued attributes

Explanation

2NF eliminates partial dependencies: every non-prime attribute must depend on the whole primary key, not just part of a composite key. This builds on 1NF, which requires atomic attribute values.

Question 34Computer Science (subject content as per PSEB syllabus)

What is the output of the following C code? int a = 5, b = 2; float c = a / b; printf("%.1f", c);

  1. 3.0
  2. 2.0 Correct answer.
  3. 2
  4. 2.5

Explanation

Both a and b are integers, so a / b performs integer division, yielding 2. That integer 2 is then converted to float and stored in c, so the output is 2.0 with one decimal place.

Question 35Computer Science (subject content as per PSEB syllabus)

Which SQL statement is used to remove a table and all its data from a database?

  1. DROP TABLE table_name; Correct answer.
  2. REMOVE TABLE table_name;
  3. DELETE FROM table_name;
  4. TRUNCATE TABLE table_name;

Explanation

The DROP TABLE statement removes the table definition and all its rows from the database schema. It is a data definition language (DDL) command.

Question 36Computer Science (subject content as per PSEB syllabus)

In a C program, what is the effect of the declaration int *p; ?

  1. p is a pointer to an integer Correct answer.
  2. p is an array of integers
  3. p is a function returning an integer
  4. p is an integer variable

Explanation

The asterisk in the declaration int *p; indicates that p is a pointer variable that can hold the address of an integer. The type of the object pointed to is int.

Question 37Computer Science (subject content as per PSEB syllabus)

Which network device forwards data packets between different networks based on IP addresses?

  1. Repeater
  2. Router Correct answer.
  3. Hub
  4. Switch

Explanation

A router operates at the network layer and uses IP addresses to determine the best path for forwarding packets between networks. It connects distinct subnets.

Question 38Computer Science (subject content as per PSEB syllabus)

What is the output of the following C code? int i; for (i = 0; i < 3; i++) printf("%d", i);

  1. 1234
  2. 0123
  3. 123
  4. 012 Correct answer.

Explanation

The loop starts with i = 0 and runs while i < 3, printing 0, 1, and 2 in sequence. When i becomes 3, the condition fails and the loop stops, so the output is 012.

Question 39Computer Science (subject content as per PSEB syllabus)

Which of the following is a valid IPv4 address?

  1. 192.168.1.1 Correct answer.
  2. 192.168.1
  3. 192.168.1.256
  4. 192.168.1.1.1

Explanation

An IPv4 address consists of four octets separated by dots, each ranging from 0 to 255. The address 192.168.1.1 satisfies this format.

Question 40Computer Science (subject content as per PSEB syllabus)

In C, what does the strcmp function return when two strings are identical?

  1. 0 Correct answer.
  2. A negative integer
  3. 1
  4. A positive integer

Explanation

The strcmp function compares two strings character by character and returns 0 if they are exactly equal. A positive or negative value indicates the first string is greater or less than the second, respectively.

Question 41Computer Science (subject content as per PSEB syllabus)

Which SQL clause is used to sort the result set of a SELECT query in ascending or descending order?

  1. HAVING
  2. ORDER BY Correct answer.
  3. WHERE
  4. GROUP BY

Explanation

The ORDER BY clause sorts the rows returned by a query, using ASC for ascending (the default) or DESC for descending order. It is applied after the WHERE and GROUP BY clauses.

Question 42Computer Science (subject content as per PSEB syllabus)

What is the hexadecimal representation of the decimal number 255?

  1. FE
  2. FF Correct answer.
  3. F0
  4. EF

Explanation

Decimal 255 equals 15×16 + 15, and 15 is represented by F in hexadecimal, so the value is FF. This is the largest two-digit hexadecimal number.

Question 43Computer Science (subject content as per PSEB syllabus)

Which of the following is the correct way to declare a function that takes two integers and returns their sum in C?

  1. int sum(a, b);
  2. void sum(int a, int b);
  3. int sum(int a, int b); Correct answer.
  4. sum(int a, int b);

Explanation

A function declaration must specify the return type, the function name, and the parameter types. The declaration int sum(int a, int b); states that sum returns an int and takes two int parameters.

Question 44Computer Science (subject content as per PSEB syllabus)

A table has columns StudentID and CourseID as a composite primary key, and also includes StudentName. Which normal form does the table violate?

  1. BCNF
  2. 2NF Correct answer.
  3. 3NF
  4. 1NF

Explanation

StudentName depends only on StudentID, which is part of the composite primary key, not on the whole key. This partial dependency violates second normal form (2NF).

Question 45Computer Science (subject content as per PSEB syllabus)

What is the output of the following C code? int x = 10; int *p = &x; *p = 20; printf("%d", x);

  1. 20 Correct answer.
  2. Address of x
  3. 0
  4. 10

Explanation

The pointer p stores the address of x, and *p = 20 assigns 20 to the memory location pointed to by p, which is x. Therefore, printing x shows 20.

Question 46Computer Science (subject content as per PSEB syllabus)

Using 8-bit two's complement representation, what is the result of adding 01111111 and 00000001?

  1. 00000000
  2. 10000001
  3. 10000000 Correct answer.
  4. 11111111

Explanation

Adding 01111111 (127) and 00000001 (1) gives 10000000, which in two's complement represents -128. This is an overflow because the sum exceeds the maximum positive value 127.

Question 47Computer Science (subject content as per PSEB syllabus)

In C, what is the output of the following code? int i = 0; while (i < 3) { printf("%d", i); i += 2; }

  1. 01
  2. 0
  3. 02 Correct answer.
  4. 012

Explanation

The loop starts with i = 0, prints 0, then adds 2 to i, making i = 2. It prints 2, adds 2 to i, making i = 4, and then the condition i < 3 fails, so the output is 02.

Question 48Computer Science (subject content as per PSEB syllabus)

A subnet mask of 255.255.255.224 is applied to a network. How many usable host addresses are available in each subnet?

  1. 32
  2. 62
  3. 14
  4. 30 Correct answer.

Explanation

The mask 255.255.255.224 has 27 network bits, leaving 5 host bits. The number of addresses per subnet is 2^5 = 32, and subtracting the network and broadcast addresses gives 30 usable hosts.

Question 49Computer Science (subject content as per PSEB syllabus)

Consider a relation R(A, B, C) with functional dependencies A → B and B → C. Which normal form does R violate?

  1. BCNF
  2. 2NF
  3. 1NF
  4. 3NF Correct answer.

Explanation

The dependency A → B and B → C creates a transitive dependency A → C, where C depends on A through B. This violates third normal form (3NF), which requires no transitive dependencies on the primary key.

Question 50Computer Science (subject content as per PSEB syllabus)

In the PSEB Computer Science syllabus, which number system uses only the digits 0 and 1 and is the basis for all data stored inside a computer?

  1. Decimal number system
  2. Binary number system Correct answer.
  3. Octal number system
  4. Hexadecimal number system

Explanation

The binary number system has base 2 and uses only the symbols 0 and 1. Because digital circuits have two stable states (on/off), every value inside a computer is ultimately stored in binary form. Decimal, octal and hexadecimal are other positional systems with larger bases used mainly for human convenience.