SSC-II Computer Science (2 Sets With Solutions) - Combined
SSC-II Computer Science (2 Sets With Solutions) - Combined
ROLL NUMBER
⓪ ⓪ ⓪ ⓪ ⓪ ⓪ ⓪ ⓪ ⓪ ⓪ ⓪
① ① ① ① ① ① ① ① ① ① ①
② ② ② ② ② ② ② ② ② ② ②
Answer Sheet No.____________
③ ③ ③ ③ ③ ③ ③ ③ ③ ③ ③
④ ④ ④ ④ ④ ④ ④ ④ ④ ④ ④
⑤ ⑤ ⑤ ⑤ ⑤ ⑤ ⑤ ⑤ ⑤ ⑤ ⑤ Sign. of Candidate ___________
⑥ ⑥ ⑥ ⑥ ⑥ ⑥ ⑥ ⑥ ⑥ ⑥ ⑥
⑦ ⑦ ⑦ ⑦ ⑦ ⑦ ⑦ ⑦ ⑦ ⑦ ⑦
Sign. of Invigilator ___________
⑧ ⑧ ⑧ ⑧ ⑧ ⑧ ⑧ ⑧ ⑧ ⑧ ⑧
⑨ ⑨ ⑨ ⑨ ⑨ ⑨ ⑨ ⑨ ⑨ ⑨ ⑨
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) What is the output of following code?
int a = 15;
float s = 5.50;
printf (“%f”, a/s);
A. 2 ⃝ B. 2.72 ⃝
C. 3 ⃝ D. 5 ⃝
(2) Which one of the following symbols is used in flow chart for the statement
“Marks<33”?
A. ⃝ B. ⃝
C. ⃝ D. ⃝
(3) Which one of the following functions is used to read string “Computer Science”?
A. scanf( ) ⃝ B. gets( ) ⃝
C. getchar( ) ⃝ D. getch( ) ⃝
(5) Which escape sequence can be used to insert a Tab in “C” Language?
A. \a ⃝ B. \b ⃝
C. \t ⃝ D. \n ⃝
(6) Which one of the following is the most suitable for making two ways decision?
A. if statement ⃝ B. if-else statement ⃝
C. switch statement ⃝ D. Nested-if statement ⃝
Page 1 of 2
(7) How many times “FBISE” will be displayed by the following code?
for (int i=1; i<10; i=+2)
printf (“FBISE”);
A. 1 ⃝ B. 5 ⃝
C. Infinite ⃝ D. The loop will not run. ⃝
B. i =1 ⃝
i =2
C. i =1 ⃝
i =3
D. i =2 ⃝
i =1
(10) When the input to an inverter is LOW(0) the output will be:
A. HIGH or 0 ⃝ B. LOW or 0 ⃝
C. HIGH or 1 ⃝ D. LOW or 1 ⃝
(12) Which one of the following is correct HTML statements to divide browser
window into 3 columns?
A. <fram col = 30%, 30%, 40%> ⃝
B. <framset col = 30%, 30%, 40%> ⃝
C. <framset col 30%, 30%, 40%> ⃝
D. <fram row = 30%, 30%, 40%> ⃝
____________________
Page 2 of 2
Federal Board SSC-II Examination
Computer Science Model Question Paper
(Curriculum 2009)
Page 1 of 2
xii. Write down the three benefits of web portal.
xiii. Use appropriate text formatting tags to define the following. Write one example
of each.
a. font size b. font colour c. font face
Q.5 i. Rewrite the following code after removing the errors: (4)
# include < std.h>
# include < conio.h>
void main ( );
{
int p, s;
printf(“\n Enter a number:);
scanf(“%d”, p);
s=p%2;
if(s=0)
printf(“even number%d”, p)
els
printf(“odd number%d”, p);
getch( );
ii. Convert the following program using switch statement: (4)
void main( )
{ char ch; clrscr( );
printf(“Enter a single character”);
scanf(“%c”, &ch);
if ( ch = = ‘a’ || ch = = ‘A’ ||
ch = = ‘e’ || ch = = ‘E’ ||
ch = = ‘i’ || ch = = ‘I’ ||
ch = = ‘o’ || ch = = ‘O’ ||
ch = = ‘u’ || ch = = ‘U’)
printf(“It is a vowel”);
else printf(“It is a consonant”); }
*****
Page 2 of 2
COMPUTER SCIENCE SSC-II
(Curriculum 2009)
Student Learning Outcomes
5 A: 1(v) 3.1 Input / Output vi) Explain the use of the following escape K 1
functions sequences using programming examples: •
Alert - \a • Backspace – \b • Newline – \n •
Carrage Return – \r • Tab – \t
6 A: 1(vi) 4.1 Control vi) Use if-else statement K 1
Structure
7 A: 1(vii) 5.1 Loop ii) Know that for loop structure is A 1
Structure composed of: • For • Initialization
expression • Test expression • Body of the
loop • Increment / decrement expression
8 A: 1(viii) 5.1 Loop Structure ii) Know that for loop structure is U 1
composed of: • For • Initialization
expression • Test expression • Body of the
loop • Increment / decrement expression
9 A: 1(ix) 6.2 Logic Gates iv) Explain the following logic gates U 1
with the help of truth tables:
• AND • OR • NAND • NOR • NOT
10 A: 1(x) 6.2 Logic Gates iv) Explain the following logic gates K 1
with the help of truth tables:
NOT
**Cognitive Level
K: Knowledge
U: Understanding
A: Application
COMPUTER SCIENCE SSC-II
Table of Specifications
Unit 1: Unit 2: Unit 3: Unit 4: Unit 5: Unit 6: Unit 7: World Total
Programmi Program Input / Control Loop Computer Wide Web and marks
%
ng ming in C Output Structur Structure Logic and HTML(Major part (55
15% Mark Theory Covere
Assessment Objectives Technique Handling e Gates cover in Practical)
s + 25 d
s
10% 10% 15% 15% 15% 20% Practical)
100%
Section - A 1(5)(01) 1(6)(01) 1(10)(01) 03
Knowledge Section - B 2(i)(03) 2(iii)(03) 2(v)(03) 2(vi)(03) 2(xiii)(03)
15 22 29.3%
based
Section - C 3-(04) 04
Section - A 1(2)(01) 1(1)(01) 1(8)(01) 1(9)(01) 1(11)(01)
1(3)(01) 1(12)(01) 08
Understanding 1(4)(01)
based Section - B 2(ii)(03) 2(vii)(03) 2(ix)(03) 2(x)(03) 2(xii)(03) 18 50.7%
2(xi)(03) 38
* Unit 7: Major content will examine in Practical paper. 10% covered in Theory paper and remaining will cover in Practical paper.
Hence weightage distributed to other units.
KEY: 1(1)(01)
Question No (Part No.) (Allocated Marks)
Federal Board SSC-II Examination
Computer Science Solution of Model Question Paper
(Curriculum 2009)
SECTION – A
Note: Section-A is compulsory and comprises two pages. All parts of this section are to be
answered on the question paper itself. It should be completed in the first 20 minutes and
handed over to the Centre Superintendent. Do not use lead pencil.
(Answers are bold and underlined)
(1) What is the output of the following code?
int a = 15;
float s = 5.50;
printf (“%f”, a/s);
A. 2 B. 2.72
C. 3 D. 5
(2) Which one of the following symbols is used in flow chart for the statement
“Marks<33”?
A. B.
C. D.
(3) Which one of the following functions is used to read string “Computer Science”?
A. scanf( ) B. gets( )
C. getchar( ) D getch( )
.
(4) Which statement is equivalent to “j=j+a;”?
A. j+=a; B. j=+a;
C. j++a; D. j=a++;
(5) Which escape sequence can be used to insert a Tab in “C” Language?
A. \a B. \b
C. \t D. \n
(6) Which one of the following is the most suitable for making two ways decision?
A. if statement B. if-else statement
C. switch statement D. Nested-if statement
(7) How many times “FBISE” will be displayed by the following code?
for (int i=1; i<10; i=+2)
printf (“FBISE”);
A. 1 B. 5
C. Infinite D. The loop will not run.
(8) What is the output of the following code?
int i ;
for(i=1;i<=2;i++)
printf (“\n i=%d”, i);
A. i=2 B. i =1
i=3 i=2
C. i =1 D. i =2
i=3 i=1
(10) When the input to an inverter is LOW(0) the output will be:
A. HIGH or 0 B. LOW or 0
C. HIGH or 1 D. LOW or 1
(12) Which one of the following is correct HTML statements to divide browser
window into 3 columns?
A. <fram col = 30%, 30%, 40%>
B. <framset col = 30%, 30%, 40%>
C. <framset col 30%, 30%, 40%>
D. <fram row = 30%, 30%, 40%>
Federal Board SSC-II Examination
Computer Science Solution of Model Question
Paper
(Curriculum 2009)
Q.2 Attempt any NINE parts from the following. All parts carry equal marks. (9 3 = 27)
i. What is an algorithm and what is the role of algorithm in problem solving?
Answer:
Algorithm means method, procedure, technique or plan. Algorithm is a step-by-
step problem-solving method that is easy to understand and follow. It is a set of
steps that clearly defines a sequence of operations to solve a problem.
ROLE OF ALGORITHM IN PROBLEM SOLVING
Algorithm plays an important role in computer programming. Computer
programming is the process of taking an algorithm and coding it in a programming
language. Formulating an algorithm is the first step for developing a computer
program.
ii. Point out valid and invalid variable names.
Answer:
a. define Invalid b. 5name Invalid
c. a5 Valid d. US$ Invalid
e. a_b Valid f. f name Invalid
iii. Write two advantages and one disadvantage of compiler.
Answer:
Advantage:
A compiler is a computer software that translates entireC language program (source
program) into machine code (object program) that can be understood and executed
by the computer
It also detects syntax errors in the source program and gives hints to the
programmer to correct them.
Disadvantage:
It occupies extra memory since it needs to generate a new file.
iv. Evaluate each of the following expression assuming, a is 2, z is 1.3, c is 1 and d is 3:
a. b = d/a + d % a
b = 3/2 + 3 % 2
b=1+3%2
b=1+1
b=2
b. x = (a + c)/(z + 0.3)
x = (2 + 1)/( 1.3+ 0.3)
x = (3)/(1.3+ 0.3)
x = 3/1.6
x =1.875
c. y=c/d*a
y=1/3*2
y=0*2
y=0
v. Write down the name and purpose of any three format specifiers.
Answer:
NAMES OF FORMAT SPECIFIERS:
%d decimal integer
%f floating-point (decimal notation)
%c single character
Integer Format Specifiers (%d)
The format specifier %d is used to read or print a decimal integer.
Floating-point Format Specifiers (%f)
The format specifier %f is used to read and print floating-point numbers in decimal
notation with a precision of 6 digits after the decimal point.
The Character Format Specifier (%c)
The character format specifier, %c, is used to read or print a single character.
vi. Define the following.
Answer:
i. Control Statement
Control Statements in C are used to execute/transfer the control from one part
of the program to another depending on a condition. These statements are also
called as conditional statements.
ii. Conditional Statement
Conditional Statements in C programming are used to make decisions based on the
conditions. Conditional statements execute sequentially when there is no condition
around the statements. It is also called as branching as a program decides which
statement to execute based on the result of the evaluated condition.
vii. What is the conditional operator? Give an example.
Answer:
The conditional operator is also known as a ternary operator. The conditional
statements are the decision-making statements which depend upon the output of the
expression. It is represented by two symbols, i.e. '?' and ‘:’. Conditional operators
return one value if condition is true and returns another value is condition is false.
Syntax: (Condition? expression1: expression2);
Example: J= (A > 100)? C*D: C+D;
In above example, if A is greater than 100, then product of C and D will be assigned
to J otherwise sum of Cand D will be assigned. This is equal to if else conditional
statements.
viii. Write a program using while loop to print odd numbers from 1 to 20.
Answer:
#include<stdio.h>
#include<conio.h>
int main()
{
int n;
n=1;
while(n<=20)
{
printf("%d\n",n);
n=n+2;
}
getch();
return 0;
}
ix. What will be the output of the following code?
void main( ) { int u, i;
for (u = 1; u< = 5; u++)
{ for (i = 1; i< = u; i++)
{printf(“%d \t”, i);}
printf(“\n”);
} }
OUTPUT:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
x. Construct Truth Table for the following Boolean Expression:
F = x yz + x yz + x y
Answer:
X Y Z =y = +yyz
zx+ +
yzyx+yx y
=x
FF +zxx
Fxzy +xx
yz F = x yz + x yz + x y
0 0 0 0 0 0 0
0 0 1 1 0 0 1
0 1 0 0 0 0 0
0 1 1 0 1 0 1
1 0 0 0 0 1 1
1 0 1 0 0 1 1
1 1 0 0 0 0 0
1 1 1 0 0 0 0
xi. Convert the following code into for loop:
int sum = 0, num= 0;
do {
sum = sum + num;
printf (“Enter an integer value”);
scanf(“%d”, &num); }
while (num> = 0 &&num< = 15);
Answer:
int sum = 0, num= 0;
for(int num=0;num>=0 &&num<=15;)
{
sum=sum+num;
printf(“Enter an integer value”);
scanf(“%d”, &num);
}
xii. Write down benefits of web portal. Give one example.
Answer:
Web portal is a website that offers a large variety of services these include online
shopping malls, news stock prices, email search engines, etc. Web portals function
as a point of access to information on the web.
For example, A school web portal delivers information about the school’s historical
background, admission requirement, School curriculum, tuition fees structure,
School news, student results in a unified way.
xiii. Use appropriate text formatting tags to define the following. Write example of each.
Answer:
a. font size
In HTML, <fontsize=?></font> these tags are used to change the font size.
Replace ? symbol with the number in the range 1 to 7. One is the smallest and
seven is the largest font size.
For Example <fontsize=3>Information Technology</font>
ȳ ȳ y Y
0 1 1 0
+ x yz + x y z + xyz + x yz
x 1 1 1 1
F=x+z
Logic Circuit:
Q.5 i. Rewrite the following code after removing the errors: (4)
# include <std.h>
# include <conio.h>
void main ( );
{
int p, s;
printf(“\n Enter a number:);
scanf(“%d”, p);
s=p%2;
if(s=0)
printf(“even number%d”, p)
els
printf(“odd number%d”, p);
getch( );
Solution:
# include <stdio.h>
# include <conio.h>
void main ( )
{
int p, s;
printf(“\n Enter a number:);
scanf(“%d”, &p);
s=p%2;
if(s==0)
printf(“even number%d”, p);
else
printf(“odd number%d”, p);
getch( );
}
ii. Convert the following program using switch statement: (4)
void main( )
{ char ch; clrscr( );
printf(“Enter a single character”);
scanf(“%c”, &ch);
if ( ch = = ‘a’ || ch = = ‘A’ ||
ch = = ‘e’ || ch = = ‘E’ ||
ch = = ‘i’ || ch = = ‘I’ ||
ch = = ‘o’ || ch = = ‘O’ ||
ch = = ‘u’ || ch = = ‘U’)
printf(“It is a vowel”);
else printf(“It is a consonant”); }
Solution:
void main( )
{ char ch;
clrscr( );
printf(“Enter a single character”);
scanf(“%c”, &ch);
switch(ch)
{
case ‘a’:
case ‘e’:
case ‘i’:
case ‘o’:
case ‘u’:
case ‘A’:
case ‘E’:
case ‘I’:
case ‘O’:
case ‘U’:
printf(“It is a vowel”);
break;
default:
printf(“It is a consonant”);
}
}
*****
NOTE:
This is suggested (proposed) solution or answers to the questions given in SECTION-B and
C. Students can write any valid alternate answers.
Version No. ROLL NUMBER
⓪ ⓪ ⓪ ⓪ ⓪ ⓪ ⓪ ⓪ ⓪ ⓪ ⓪
① ① ① ① ① ① ① ① ① ① ①
② ② ② ② ② ② ② ② ② ② ②
Answer Sheet No.____________
③ ③ ③ ③ ③ ③ ③ ③ ③ ③ ③
④ ④ ④ ④ ④ ④ ④ ④ ④ ④ ④
⑤ ⑤ ⑤ ⑤ ⑤ ⑤ ⑤ ⑤ ⑤ ⑤ ⑤ Sign. of Candidate ___________
⑥ ⑥ ⑥ ⑥ ⑥ ⑥ ⑥ ⑥ ⑥ ⑥ ⑥
⑦ ⑦ ⑦ ⑦ ⑦ ⑦ ⑦ ⑦ ⑦ ⑦ ⑦
Sign. of Invigilator ___________
⑧ ⑧ ⑧ ⑧ ⑧ ⑧ ⑧ ⑧ ⑧ ⑧ ⑧
⑨ ⑨ ⑨ ⑨ ⑨ ⑨ ⑨ ⑨ ⑨ ⑨ ⑨
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 expression where 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 expression where 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 ⃝
(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 2 of 2
Federal Board SSC-II Examination
Computer Science Model Question Paper
(Curriculum 2009)
xi. Differentiate between ordered list and unordered list used in HTML. (3)
xii. Define the following terms: (1+1+1)
a. Web-Hosting b. Web-Server c. Hyper-Link
xiii. Differentiate between Frame and Frame set by giving one example used in
HTML. (3)
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
Page 1 of 2
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.
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)
Q.5 a. Briefly describe NOR and Exclusive NOR(XNOR) logic gate with circuit
diagram and truth table. (4)
b. Define Karnaugh Map(K-Map) also write the simplification rules for three
variable Karnaugh Map. (4)
*****
Page 2 of 2
COMPUTER SCIENCE SSC-II (2nd Set)
(Curriculum 2009)
Student Learning Outcomes Alignment Chart
**Cognitive Level
K: Knowledge U: Understanding A: Application
COMPUTER SCIENCE SSC-II (2nd Set)
Table of Specification
UNIT 1 Unit 2: ROGRAMMING Unit 3: INPUT / Unit 4: Unit 5: LOOP Unit 6: Unit 7: Cognitive
PROGRAMMING IN C 10% OUTPUT CONTROL STRUCTURE COMPUTER WORLD level Total
Assessment TECHNIQUES 10% HANDLINGC++ STRUCTURE 15% LOGIC AND WIDE WEB
Cognitive
marks: 75
Cognitive
Objectives level Marks level %
15% 15% GATES15% AND HTML
20%
Section A 1-ii-(01) 1-iii-(01) 1-v-(01) 1-xi-(01)
05
Knowledge
1-iv-(01)
Section B 2-i-(03) 2-iii-(03) 2-xii-(03) 22 29.3%
09
Section C 5(08) 08
Section A 1-i-(01) 1-vi-(01) 1-viii-(01) 1-x-(01) 1-xii-(01)
1-vii-(01) 1-ix-(01)
Understanding
07
Section B 2-ix-(03) -
16 21.3%
Section C 3(05) 4(08)
16
Total marks 8 8 12 12 12 12 11 75 100%
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
(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)
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.
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
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 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.
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.
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
Testing if-else statement test for equality switch statement test only
as well as for logical expression. for equality.
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.
<ul> and </ul> tags are used. <ol> and </ol> tags are used.
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 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.
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.
*****