You are on page 1of 26

Happy Home School

Clifton Campus

Practical File
Grade X
Topics: Programming in C
Algorithms (Pseudocode & Flowchart)
Spreadsheets(MS Excel)
CERTIFICATE
This is to certify that Mr./Miss. of class has
carried out the necessary practical prescribed by the Agha Khan
University Examination Board of the year 2022-23.

_____________________ ____________________

Signature Seal and Signature


(Teacher:Computer Science) Head of Institution

Programming
1 To find the volume of a cube, cylinder, or sphere

2 To find the area of a triangle, parallelogram, rhombus, and trapezoid

3 To calculate the exponent of a given number


4 To convert Celsius to Fahrenheit temperature and vice versa

5 To Prepare an electricity bill


6 To Calculate the GCD (greatest common divisor) of given two numbers

7 To find the interest in an amount

8 To find the sum, product, and average of five given numbers

9 To find the acceleration of a moving object with a given mass and the force applied
10 To find even numbers in integers ranging from n1 and n2 (where n1 is greater than n2)

11 To determine prime numbers in integers ranging from n1 to n2 (where n1 is greater than


n2)
12 To count multiple of a given number lying between two numbers

13 To find the maximum number from input values.

14 To find the minimum number from input values.

15 To determine whether a given number is prime or not


16 To display the larger one out of the three given unequal numbers

17 To assign a grade to a subject based on the achieved marks

18 To find the sequence of odd numbers starting from a given number

19 To produce a multiplication table for a given number

Index
Office Automation II: Spreadsheets(MS Excel)
1 Prepare a spreadsheet by naming cells and sheets.
2 Use different options of paste special, i.e. value, format and formula.
3 Print a spreadsheet.
4 Apply cell formatting tools like; number, alignment, font, border, fill.
5 Apply different functions to the data, i.e sum, average, count, minimum and maximum.
6 Insert a pie chart and bar graph in the data sheet.
7 Apply filter and data validation on spreadsheet data.
8 Protect a worksheet.
9 Lock/ unlock cells of spreadsheet.
1. To find the volume of a cube, cylinder, or sphere
#include <stdio.h>
#include <math.h>

int main() {
int shape;
float side, radius, height, volume;
const float PI = 3.14159;

printf("Enter the shape (1 for cube, 2 for cylinder, 3 for sphere): ");
scanf("%d", &shape);
switch(shape) {
case 1:
printf("Enter the length of one side of the cube: ");
scanf("%f", &side);
volume = pow(side, 3);
printf("The volume of the cube is %.2f cubic units.\n", volume);
break;

case 2:
printf("Enter the radius and height of the cylinder: ");
scanf("%f %f", &radius, &height);
volume = PI * pow(radius, 2) * height;
printf("The volume of the cylinder is %.2f cubic units.\n", volume);
break;

case 3:
printf("Enter the radius of the sphere: ");
scanf("%f", &radius);
volume = (4.0/3.0) * PI * pow(radius, 3);
printf("The volume of the sphere is %.2f cubic units.\n", volume);
break;

default:
printf("Invalid input.\n");
}

return 0;
}
2. To find the area of a triangle, parallelogram, rhombus, and
trapezoid
#include <stdio.h>

int main() {
int choice;
float base, height, side1, side2, diag1, diag2, height2, sob;

printf("Enter your choice:\n1. Triangle\n2. Parallelogram\n3. Rhombus\n4. Trapezoid\n");


scanf("%d", &choice);

switch(choice) {
case 1:
printf("Enter the base and height of the triangle: ");
scanf("%f %f", &base, &height);
printf("Area of the triangle is: %.2f\n", 0.5 * base * height);
break;

case 2:
printf("Enter the base and height of the parallelogram: ");
scanf("%f %f", &base, &height);
printf("Area of the parallelogram is: %.2f\n", base * height);
break;

case 3:
printf("Enter the diagonal1, diagonal2 of the rhombus: ");
scanf("%f %f", &diag1, &diag2);
printf("Area of the rhombus is: %.2f\n", 0.5 * diag1 * diag2);
break;

case 4:
printf("Enter the sum of bases and height of the trapezoid: ");
scanf("%f %f", &sob, &height2);
printf("Area of the trapezoid is: %.2f\n", 0.5 * (sob) * height2);
break;

default:
printf("Invalid choice.\n");
break;
}

return 0;
}
10. To find even numbers in integers ranging from n1 and n2 (where
n1 is greater than n2)
#include <stdio.h>

int main() {
int n1, n2, i;

printf("Enter the range of integers (n1 > n2): ");


scanf("%d %d", &n1, &n2);

printf("Even numbers in the range %d to %d are: ", n1, n2);

// loop through the range of integers


for (i = n2; i <= n1; i++) {
// check if the integer is even
if (i % 2 == 0) {
printf("%d ", i);
}
}

return 0;
}
11- To determine prime numbers in integers ranging from n1 to n2
(where n1 is greater than n2)
#include <stdio.h>

int main() {
int n1, n2, i, j, is_prime;
printf("Enter two integers (n1 > n2): ");
scanf("%d %d", &n1, &n2);
printf("Prime numbers between %d and %d are: \n", n2, n1);
for (i = n2; i <= n1; i++) {
is_prime = 1;
for (j = 2; j <= i / 2; j++) {
if (i % j == 0) {
is_prime = 0;
break;
}
}
if (is_prime && i > 1) {
printf("%d ", i);
}
}
printf("\n");
return 0;
}
12. To count multiple of a given number lying between two numbers
#include <stdio.h>
# include <conio.h>
main()
{
int i, n, d ;

printf("Enter the limit : ") ;


scanf("%d", &n) ;
printf("\nEnter the number : ") ;
scanf("%d", &d) ;
printf("\nThe numbers divisible by %d are :\n\n", d) ;
for(i = 1 ; i <= n ; i++)
if(i % d == 0)
printf("%d\t", i) ;
getch() ;
}
13. To find the maximum number from input values.
#include<stdio.h>
#include<conio.h>

int main()
{

int num,x,max;
max=0;

for(x=1; x<=10; x++)


{
printf("Enter a number :");
scanf("%d",&num);

if (num>max)
max=num;
}

printf("The maximum number is %d",max);

return 0;
}
14.To find the minimum number from input values.
#include<stdio.h>
#include<conio.h>

int main()
{

int num,x,min;
min=9999;

for(x=1; x<=10; x++)


{
printf("Enter a number :");
scanf("%d",&num);

if (num<min)
min=num;
}
printf("The minimum number is %d",min);

return 0;
}
15- To determine whether a given number is prime or not

#include <stdio.h>
#include <conio.h>
main() {
int n, i, c = 0;
printf("Enter any number n:");
scanf("%d", &n);

//logic
for (i = 1; i <= n; i++) {
if (n % i == 0) {
c++;
}
}

if (c == 2) {
printf("%d is a Prime number",n);
}
else {
printf("%d is not a Prime number",n);
}
getch();
}
18- To find the sequence of odd numbers starting from a given number

#include <stdio.h>
int main() {
int startNum, i;
printf("Enter the starting number: ");
scanf("%d", &startNum);

for (i=startNum;i<=startNum+10;i++)
{
if (i%2==1)
printf("%d ",i);
}

return 0;
}
To calculate the exponent of a given number
#include <stdio.h>
#include <math.h>
int main ()
{

int base, exp;


int result;
printf (" Enter the base value from the user: ");
scanf (" %d", &base);
printf (" Enter the power value for raising the power of base: ");
scanf (" %d", &exp);
result = pow ( base, exp);
printf (" %d to the power of %d is = %d ", base, exp, result);
return 0;
}
To Calculate the GCD (greatest common divisor) of given two
numbers
#include <stdio.h>
#include <math.h>
#include <conio.h>

int main ()
{
int Num1, Num2, i, GCD;

printf("Please Enter two integer Values \n");


scanf("%d %d", &Num1, &Num2);

for(i = 1; i <= Num1 && i <= Num2; i++)


{
if(Num1 % i == 0 && Num2 % i == 0)
GCD = i;
}

printf("GCD of %d and %d is = %d", Num1, Num2, GCD);


return 0;
}
To determine prime numbers in integers ranging from n1 to n2 (where
n1 is greater than n2)

#include <stdio.h>
#include <conio.h>
int main()
{
int n, i = 3, count, c;
printf("Enter the number of prime numbers to print\n");
scanf("%d", &n);
if (n >= 1) {
printf("First %d prime numbers are:\n",n);
printf("2\n");
}
for (count = 2; count <= n;)
{
for (c = 2; c <= i - 1; c++)
{
if (i%c == 0)
break;
}
if (c == i)
{
printf("%d\n", i);
count++;
}
i++;
}
return 0;
}
To count multiple of a given number lying between two numbers
#include <stdio.h>
# include <conio.h>
main()
{
int i, n, d ;

printf("Enter the limit : ") ;


scanf("%d", &n) ;
printf("\nEnter the number : ") ;
scanf("%d", &d) ;
printf("\nThe numbers divisible by %d are :\n\n", d) ;
for(i = 1 ; i <= n ; i++)
if(i % d == 0)
printf("%d\t", i) ;
getch() ;
}

ALGORITHM
Step 1
Take input for the limit (n) and a number (d).
Step 2
Use a for loop to iterate from 1 to n.
Step 3
Inside the loop, check if the current value of i is divisible by d (i % d == 0).
Step 4
If it is divisible, print the value of i.
Step 5
Repeat steps 3 and 4 until all values in the range have been checked.
Step 6
End the program.

You might also like