Computer Science PBA Notes SSC-II
Computer Science PBA Notes SSC-II
PBA
Askaria School & Colleges
1. Installation of C compiler:
1. Go to the official website or a trusted download site.
2. Download the latest version of Dev-C++.
3. Once downloaded, locate the installer in your Downloads folder.
4. Double-click the file to start the installation.
5. Upon launching the installer, you will be prompted to choose your preferred
language. Select your language and click OK.
6. Read the License Agreement, and if you agree with the terms, click I Agree.
7. Choose the folder where you want to install Dev-C++.
8. You will be presented with options for the components you want to install.
By default, it will include: Dev-C++ IDE, GCC Compiler and Shortcut
icons Leave the default options checked and click Install.
9. The installer will now copy all necessary files and set up Dev-C++.
10.Once the installation is complete, click Finish.
Tool Bar
Editor
Window
Compiler
Window
2.1 How To create new project?
1. Go to File option in menu bar
2. Choose New > source file
3. It will create a file you can save that file by choosing Save as option from
file menu or by pressing CTRL + S.
4. Specify a name for you file and choose type as C source file
5. Click on save button to save you file.
2.2 How To Compile and Run your file?
1. After writing code just click on the Execute option given in menu bar.
2. Choose Compile and Run option or press F11
3. Compiler will check your code if there is any error it will show that in
compiler window. Otherwise, it will show an output console to you.
3. Printf, Scanf and getch statements: Program to find sum of
two numbers
#include<stdio.h>
#include<conio.h>
void main(void)
{
int num1,num2,sum;
printf(“Enter first number:”);
scanf(“%d”, &num1);
printf(“\n Enter second number:”); Enter first number:10
scanf(“%d”,&num2); Enter second number:5
sum=num1+num2; Sum of two numbers is=15
printf(“Sum of two numbers is=%d”,sum);
getch();
}
Output:
1.2. HTML Ordered List with Letters:
<html>
<body>
<h2>Ordered List with Letters</h2>
<ol type="A">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
</body>
</htm|>
Output:
Output:
2.3. Backgrounds:
<html>
<body style="background-color:powderblue”>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
Output:
3. Hyperlinks:
The <a> tag defines a hyperlinks which is use to link from one page to
another. The most important attributes of the <a> elements is the href
attribute, which indicate the link’s destination.
<html>
<body>
<a href= "https://www.KSschools.com">Welcome to our school! </a>
</body>
</html>
Output:
4. Tables:
An HTML table is defined with the <table> tag.
Each table row is defined with the <tr> tag. A table header is defined with the <th>
tag. A table data is defined with the <td> tag
<html>
<body>
<h2>Basic HTML Table</h2>
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Jalil</td>
<td>Saqib</td>
<td>50</td>
</tr>
<tr>
<td>Ali</td>
<td>Awas</td>
<td>94</td>
</tr>
<tr>
<td>Munir</td>
<td>Shah</td>
<td>80</td>
</tr>
</table>
</body>
</html>
Output:
__________________________________________________________
Practice sheet:
Question No. 1 [Marks: 06]
i. Rearrange the lines in the correct order, so that the program compares two
numbers entered by the user and displays the larger number. [Marks: 2]
{
if (a > b)
printf("Larger number = %d", a);
else
printf("Larger number = %d", b);
printf("Enter the first number: ");
scanf("%d", &a);
scanf("%d", &b);
printf("Enter the second number: ");
int a, b;
#include <stdio.h>
void main(void)
}
ii. Modify the above program so that it also checks if both numbers are equal, and
displays an appropriate message. [Marks: 3]
iii. Write down the output of the program when the input numbers are 8 and 8.
[Marks: 1]
Question No. 2 [Marks: 6]
Write a C program to solve a quadratic equation of the form ax² + bx + c = 0. The
program should prompt the user to input the coefficients a, b, and c, and should
then calculate the roots using the quadratic formula.
Requirements:
i. Input: [Marks: 2]
The program should prompt the user to enter the values of a, b, and c.
ii. Processing: [Marks: 3]
The program should calculate the roots using the formula:
−𝑏 ± √𝑏 2 − 4𝑎𝑐
𝑥=
2𝑎
iii. Output: [Marks: 1]
The program should display the roots of the equation. If the discriminant is
negative, it should print "No real roots."