0% found this document useful (0 votes)
215 views10 pages

Computer Science SSC-II Solution of 2nd Set Model Paper

The document appears to be a past exam paper for a Computer Science SSC-II exam. It contains a cover page with student details, instructions, and sections A and B. Section A contains 12 multiple choice questions testing core CS concepts. Section B contains 9 short answer questions testing algorithms, structured programming elements, header files, and differences between printf and puts functions.

Uploaded by

Jasarat Hussain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
215 views10 pages

Computer Science SSC-II Solution of 2nd Set Model Paper

The document appears to be a past exam paper for a Computer Science SSC-II exam. It contains a cover page with student details, instructions, and sections A and B. Section A contains 12 multiple choice questions testing core CS concepts. Section B contains 9 short answer questions testing algorithms, structured programming elements, header files, and differences between printf and puts functions.

Uploaded by

Jasarat Hussain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Version No.

ROLL NUMBER


⓪ ⓪ ⓪ ⓪ ⓪ ⓪ ⓪ ⓪ ⓪ ⓪ ⓪
① ① ① ① ① ① ① ① ① ① ①
② ② ② ② ② ② ② ② ② ② ②
Answer Sheet No.____________
③ ③ ③ ③ ③ ③ ③ ③ ③ ③ ③
④ ④ ④ ④ ④ ④ ④ ④ ④ ④ ④
⑤ ⑤ ⑤ ⑤ ⑤ ⑤ ⑤ ⑤ ⑤ ⑤ ⑤ Sign. of Candidate ___________
⑥ ⑥ ⑥ ⑥ ⑥ ⑥ ⑥ ⑥ ⑥ ⑥ ⑥
⑦ ⑦ ⑦ ⑦ ⑦ ⑦ ⑦ ⑦ ⑦ ⑦ ⑦
Sign. of Invigilator ___________
⑧ ⑧ ⑧ ⑧ ⑧ ⑧ ⑧ ⑧ ⑧ ⑧ ⑧
⑨ ⑨ ⑨ ⑨ ⑨ ⑨ ⑨ ⑨ ⑨ ⑨ ⑨

COMPUTER SCIENCE SSC–II (2nd Set Solution)


SECTION – A (Marks 12)
Time allowed: 15 Minutes

Section – A is compulsory. All parts of this section are to be answered on this page and handed
over to the Centre Superintendent. Deleting/overwriting is not allowed. Do not use lead pencil.

Q.1 Fill the relevant bubble for each part. Each part carries one mark.
(1) Which symbol is used to obtain the total marks from the values given by users, in
the flow chart development?
A. Rectangle B. Parallelogram ⃝
C. Diamond ⃝ D. Oval ⃝
(2) Which one of the following problem-solving stage refers to dividing the solution
into steps and arranging in order to solve the problem?
A. Planning B. Analyzing ⃝
C. Defining ⃝ D. Selecting ⃝
(3) Which of the software examines the values stored in variables and help in finding
and removing the errors?
A. Loader ⃝ B. Linker ⃝
C. Editor ⃝ D. Debugger
(4) What is the range of numbers that can be stored in a variable of type float?
A 10-38 - 1038 B. 10-308 - 10308 ⃝
C. 10 – 10
38 38
⃝ D. -38
10 - 10 32

(5) Which symbol with the variable, refers to the memory location in scanf()
function:
A. # ⃝ B. $ ⃝
C. % ⃝ D. &
(6) What is the value of “z” after evaluating the given expressionwhere a = 5, b = 3?
z = b / 2 + b * 4 / b && b < a + a / 3
A. 5 ⃝ B. 0 ⃝
C. 1 D. 6 ⃝
(7) What is the value of “z” after evaluating the given expressionwhere x=10, y=3?
z = 4*++x ||--y<x%2&&x+y
A. 41 ⃝ B. 0 ⃝
C. 1 D. 40 ⃝

Page 1 of 2
(8) What is the output of the following codes where a=1 and b= 5?
if (a-b<6)
printf(“%d”, a);
else
printf(“%d”, b);
printf(“%d”, a+b);
A. 1 ⃝ B. 5 ⃝
C. 15 ⃝ D. 16

(9) Which one of the following is a valid statement for “For loop”?
A. for(;;) ⃝ B. for(int I =1; ;) ⃝
C. for(; ;k++) ⃝ D. All of these

(10) Which logic gate is represented by the function = (𝑥𝑦)?


A. NAND B. NOR ⃝
C. Exclusive-OR ⃝ D. Exclusive-NOR ⃝

(11) A computer that makes the web pages available through the internet is called:
A. website ⃝ B. web-server
C. web-browser ⃝ D. web-link ⃝

(12) Which part of the web address tell the server type of file is being requested?
A. www ⃝ B. http://
C. .html ⃝ D. URL ⃝

______________

Page 2of 2
Federal Board SSC-II Examination
Computer Science Model Question Paper
(Curriculum 2009)

Time allowed: 2.45 hours Total Marks: 43

Note: Answer any nine parts from Section ‘B’ and attempt any two questions from Section ‘C’
on the separately provided answer book. Write your answers neatly and legibly.

SECTION – B (Marks 27)


Q.2 Attempt any NINE parts from the following. All parts carry equal marks. (9  3 = 27)
i. What are the features to select the best solution of a problem?(1+1+1)
Ans. The selection of final solution of a problem should be based on the following
criteria.
Speed: The selected solution of the problem should be efficient. In other words, it
means when the solution is implemented in a programming language, the program
should run fast.
Cost: The selected solution of the problem should provide a cost-effective way of
implementation.
Complexity: The selected solution of the problem should not be complicated. It
should contain minimum number of instructions/simple steps.

ii. Write an algorithm to find the sum, product and average of five given numbers?
(1+1+1)
Ans. Algorithm:
Start:
Input: five numbers
Step 1 : input a,b,c,d,e
Step 2: sum=0,average=0 , product=1
Step 3: sum = a+b+c+d+e
Step 4: average = sum /5
Step 5: product= a*b*c*d*e

Output: the sum, product and average

Step 6: print sum.


Step 7: print product.
Step 8: print average.
Stop:

iii. Briefly describe the three fundamental element of structured programming in C


language? (1+1+1)
Ans. Structured languages consist of three fundamental elements, which are sequence,
selection and repetition.
Sequence: It means, writing program statements in a logical sequence. Each step
in the sequence must logically progress to the next without producing any
undesirable effects.
Selection: It allows the selection of any number of statements based on the result
of evaluation of a condition which may be true or false. Examples of statements
that implement selection in programming are if, else-if, switch, etc.
Repetition (loop): It means executing one or more statements a number of times
until a condition is satisfied. Repetition is implemented in programs using
statements, such as for and while loops.

iv. What happens if header-files were not used in C program? List at-least two
header-files with their purpose (1+2)
Ans. If we are not including header file than we will not be able to use functions like
printf() or scanf(). These functions are premade in stdio.h
stdio.h Mainly used to perform input and output operations like
printf(),scanf()
string.h Mainly used to perform string handling operations like strlen(),
strcmp() etc.
conio.h With this header file, you can execute console input and output
operations.
math.h Mainly used to perform mathematical operations like sqrt(),pow()
etc.

v. Compare printf() and puts() function with at-least one example. (3)
Ans.
printf() puts()

It is used to display all types of data It is used to display only string data
and messages. and messages.

It requires a format specifier to It does not require a format specifier


display formatted data. to display string.

It can display multiple data at a time It is used to display only one string at
by multiple format specifiers in one a time.
printf( ).

Syntax: Syntax:
printf(“list of format specifier or puts(variable);
message”, list of variables);

Example: Example:
intx,y; char ch[]="Hello";
printf ("%d%d",x,y); puts(ch);

vi. Write at-least three differences between format specifiers and escape sequence
characters. (3)
Ans.

Escape sequences Format specifier

In C language Escape sequences are In C language format specifiers are


mostly used in printf() function to take used in printf() and scanf() functions
the control to specified point. to specify the type of variable the
Escape sequences Format specifier

function is dealing with.


Escape sequences are not mandatory Format specifier are mandatory part of
part of printf() function. scanf() function and in printf()
mandatory if variable or expression is
used.
Common Escape sequences are: Common format specifiers are:
\n New line %c Prints a single character
\t Horizontal tab space Read a character
\r Carriage return %d Prints a decimal integer
\b Backspace Read a signed decimal integer
\f Form feed %f Prints a floating point
\a Beep sound Read floating point number
\’ Single quote %s Prints a String
\” Double quote Read a string (till null
\\ Backslash character)

Syntax: Syntax:
printf(“list of format specifier or printf(“list of format specifier or
message or escape sequence”, list of message”, list of variables);
variables);

Example: Example:
For example \n takes the control to %c Prints a single character
new line, and \t prints a tab space. Read a character
%d Prints a decimal integer
Read a signed decimal integer

vii. Draw precedence table of operators used in the following expression: (3)
z = !(4*++x-y || x==y/--y<x%2&&x+++y)
Ans.
No. Operator Description
1 ++ -- increment/ decrement
2 * / % Multiplication/division/modulus
3 + - Addition/subtraction
4 Relational less than/less than or equal to
< <=
Relational greater than/greater than or
> >=
equal to
5 == != Relational is equal to/is not equal to
6 && Logical AND
7 || Logical OR
8 = Assignment
viii. Differentiate between if-else-if and switch structure. (3)
Ans.

Criteria IF-ELSE-IF SWITCH

Basic It's determines the statement which It's determines the statement
will be executed depend upon the which will be executed is
output of the expression inside if decided by user
statement

Expression if-else statement uses multiple switch statement uses single


statement for multiple choices. expression for multiple
choices.

Testing if-else statement test for equality switch statement test only
as well as for logical expression. for equality.

Evaluation if statement evaluates integer, switch statement evaluates


character, pointer or floating-point only character or integer
type or boolean type. value.

Sequence Either if statement will be switch statement execute


of executed or else statement is one case after another till a
Execution executed. break statement is appeared
or the end of switch
statement is reached.

ix. Default If the condition inside if If the condition inside switch


Execution statements is false, then by default statements does not match
W the else statement is executed if with any of cases, for that
r created. instance the default
i statements is executed if
t created.
e
a code that prints the given sequence of numbers on a single line also print its
sum by using any loop. (2+1)
30 27 24 21 18 15 12 9 6 3 0 -3 -6 -9
Ans. for(i=30; i<=-9; i-=3)
{
printf(“%d ”, i);
sum+=i;
}
printf(“\n The sum of series is %d”, sum);

x. Write the output of each gate shown in the following figure: (3)

Ans. x̄

x̄ ȳz
x̄ yz
x ȳ
f= x̄ ȳz+ x̄ yz+ x ȳ
xi. Differentiate between ordered list and unordered list used in HTML. (3)
Ans.

Unordered list Ordered list

In an ordered list, each item is


In an unordered list, each item is
displayed along with the numbers or
displayed with a bullet.
letters instead of bullets.

It is also known as bulleted list. It is also known as number list.

UL is an Unordered List. OL is an Ordered List.

<ul> and </ul> tags are used. <ol> and </ol> tags are used.

xii. Define the following terms: (1+1+1)


a. Web-Hosting b. Web-Server c. Hyper-Link
Ans. a. Web-Hosting: is an online service that allows you to publish your website files
onto the internet. So, anyone who has access to the internet has access to your
website.

b. Web-Server: is a computer where the web content is stored. Basically, web


server is used to host the web sites but there exist other web servers also such as
gaming, storage, FTP, email etc.

c. Hyper-Link: is a word, phrase, or image that you can click on to jump to a new
document or a new section within the current document.

xiii. Differentiate between Frame and Frame set by giving one example used in
HTML. (3)
Ans.

Frame Frame-set

Frame allows dividing a browser Frame set consist of a collection of


window into multiple sections. frames in the browser.

Frame holds a separate document. Frameset holds one or more frames.

Frame has the attributes such as Frame has the attributes such as cols,
frameborder, marginwidth, rows…..
marginheight, name, ……
SECTION – C(Marks 16)
Note: Attempt any TWO questions. (8  2 = 16)
Q.3 Write a C program to input electricity unit charge and calculate the total electricity bill
according to the given condition: (5+3)
For first 50 units Rs. 0.50/unit
For next 100 units Rs. 0.75/unit
For next 100 units Rs. 1.20/unit
For unit above 250 Rs. 1.50/unit
An additional surcharge of 20% is added to the bill.
Also justify your selection of conditional control structure.

Ans. #include <stdio.h>


int main()
{
int unit;
floatamt, total_amt, sur_charge;
printf("Enter total units consumed: ");
scanf("%d", &unit);
if(unit <= 50)
{
amt = unit * 0.50;
}
else if(unit <= 150)
{
amt = 25 + ((unit-50) * 0.75);
}
else if(unit <= 250)
{
amt = 100 + ((unit-150) * 1.20);
}
else
{
amt = 220 + ((unit-250) * 1.50);
}
sur_charge = amt * 0.20;
total_amt =amt + sur_charge;
printf("Electricity Bill = Rs. %f", total_amt);
}
Justification:
If-else-if is better choice because:
In it this statement will be executed depend upon the output of the expression inside if
statement.
Test for equality as well as for logical expression.
If statement evaluates integer, character, pointer or floating-point type or Boolean type.

Q.4 Write a program that read a number and prints its power (take it from user) if it is a prime
number otherwise print its factorial by using any control structure. (8)
Ans. #include<stdio.h>
void main()
{
intn,i,m=0,flag=0, exponent, power=1, f=1;
printf("Enter the number to check prime:");
scanf("%d",&n);
m=n/2;
for(i=2;i<=m;i++)
{
if(n%i==0)
{
printf("\n\nNumber is not prime\n\n");
flag=1;
break;
}
}
if(flag==0)
{
printf("\n Enter Exponent: ");
scanf("%d",&exponent);
while(exponent!=0)
{
power *= n;
exponent--;
}
printf("\n\nThe result of power of given No. is = %d\n\n", power);
}
else
{
for(i=1;i<=n;i++)
f=f*i;
printf("\n\nThe Factorial of %d is: %d\n\n",n,f);
}
}

Q.5 a. Briefly describe NOR and ExclusiveNOR(XNOR) logic gate with circuit
diagram and truth table. (4)
Ans.
NOR Gate:
The Logic NOR Gate gate is a combination of the digital logic OR gate and an inverter or
NOT gate connected together in series:
Truth Table+ circuit diagram:
Symbol Truth Table

B A ̅̅̅̅̅̅̅̅
Q=𝐴 +𝐵

0 0 1

0 1 0
2-input NOR Gate
1 0 0

1 1 0
Exclusive-NOR Gate:
The Exclusive-NOR Gate function is a digital logic gate that is the reverse or
complementary form of the Exclusive-OR function.
Truth Table+ circuit diagram:
Symbol Truth Table

B A Q= A ⊕ B

0 0 1

0 1 0
2-input Ex-NOR Gate
1 0 0

1 1 1

b. Define Karnaugh Map(K-Map) also write the simplification rules for three
variable Karnaugh Map. (4)
Ans. KarnaughMap(K-Map)
The K-map method of solving the logical expressions is referred to as the
graphical technique of simplifying Boolean expressions. K-maps basically insert the
values of the output variable in cells The number of cells in the K-map is determined by
the number of input variables as two raised to the power of the number of input variables
Simplification rules for three variableKarnaugh Map:
 K-Map has total of 2 rows and 4 columns which corresponds to 8 cells in 3-variable.
 Fill the K-map by entering 1 to each product-term into the K-map cell and fill the
remaining
cells with zeros.
 Form the groups by considering each one in the K-map start making groups of 2, 4,
and 8.
 Groups may be horizontal or vertical, but not diagonal.
 Grouping of 1s includes neighboring cells, corners and sides even though they overlap
each other.
 If possible, include each 1 in at least one group.
 Make larger groups if possible.
 Once all 1s are covered then you can stop.
 Find the Boolean term for each group. By looking at the common variables in cell-
labeling
 Write the simplified function in the form of sum of terms.

NOTE: This is suggested (proposed) solution to the questions given in SECTION-B and C.
Students can write any valid alternate answers.
*****

You might also like