[go: up one dir, main page]

0% found this document useful (0 votes)
9 views69 pages

XIISamplePracticalFile New2025

The document is a practical file for the Board of Intermediate Education Karachi for the session 2024-25, detailing various programming tasks in C language. It includes flow charts, algorithms, and code for practical exercises such as checking leap years, calculating factorials, and generating multiplication tables. Each practical is structured with a description, flow chart, algorithm, coding example, and expected output.

Uploaded by

forworkandlogin
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)
9 views69 pages

XIISamplePracticalFile New2025

The document is a practical file for the Board of Intermediate Education Karachi for the session 2024-25, detailing various programming tasks in C language. It includes flow charts, algorithms, and code for practical exercises such as checking leap years, calculating factorials, and generating multiplication tables. Each practical is structured with a description, flow chart, algorithm, coding example, and expected output.

Uploaded by

forworkandlogin
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/ 69

XII-Practical of Board of Intermediate Education

Karachi for the year 2024-25


NAME: ___________________________________

FATHER NAME: ___________________________________

CLASS: ___________________________________

GROUP: ___________________________________

ROLL NO: ___________________________________

EMAIL: ___________________________________

CONTACT: ___________________________________

COLLEGE: ___________________________________

SESSION: ___________________________________
Certificate

This is to certify that Mr._________ s/o_____________, holding

Roll No._______ of XI class, section [ ], has successfully completed

all the requirement of this practical file for the session 2024-25.

__________________________ ___________________________________

Course Instructor Head of the Department


(Imran Khan) (Imran Khan)
TABLE OF CONTENTS
S.No. Practical Page
No.
Part-1 C-Language Practical 5 – 58
1 Leap Year 6–8
2 Marks sheet 9 – 12
3 Table of inputted number 13 – 15
4 Factorial of inputted number 16 – 18
5 Inputting three numbers and finds greatest among the 19 – 22
three
6 Area and Volume Calculating program 23 – 26
7 Chess board (Chess/Check/Draught) Board 27 – 28
8 ASCII codes 30 – 31
9 Print name Ten (10) Times 33 – 36
10 Prime number checking program 37 – 39
11 Escape Sequences 40 – 43
12 Switch case 44 – 46
13 Pattern Printing Program 47 – 49
14 Function for summing two numbers passed as arguments 50 - 53
15 Payroll of Employee 54 – 58
C-Language
Practcial No.1 (Flow Chart- Leap Year)

Start

INPUT “Enter any year to check


whether it’s LEAP year or NOT?
”, makYear

Let factorial=1

Let counter=num

No
IF
makYear%4= 0

Yes

PRINT “Given year”,makYear,”


is LEAP year”

PRINT “Given year”,makYear,”


ISN'T leap year

Stop
Practcial No.1 (Algorithm- Leap Year)

Step1: BEGIN
Step2: DECLARE makYear AS integer
Step2: WRITE “Enter any year to check whether it’s LEAP year or
NOT? "
Step3: READ, makYear
Step4: IF (makYear%4)=1 THEN
WRITE “Given year “,makYear,” is LEAP year”
ELSE
WRITE “Given year”, makYear,” ISN’T leap year”
Step5: READ a character
Step6: END
Practcial No.1 (Coding/Programming)
/* ************************************************************************
Object: Write a program that input a year and then check whether its leap year or Not
*************************************************************************/
#include <stdio.h>
#include <conio.h>

int makYear; // variable declaration.

void main(void) // main function.

{ // start of-(sof) body of main function.

clrscr();
// below code is for showing heading of the output
printf("\n\t\t ");
printf("\n\t\tThis is sample Practical No.01");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");

printf("\n\t Enter any year to check whether it's LEAP year or NOT? "); scanf("%d",&makYear);

if(givenYear%4==0)
{printf("\n\t Given year %d is LEAP year",makYear);}
else
{printf("\n\t Given year %d ISN'T leap year",makYear);} getch();

// pause screen till any button is pressed.

} // end of-(eof) body of main function.


/************************** OUTPUT ***************************************

This is sample Practical No.01;


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter any year to check whether it's LEAP year or NOT? 1999

Given year 1999 ISN'T leap year


**************************************************************************
Practcial No.2 (Flow Chart- Marks sheet)
Start Let counter=0
A

Let total=0 NO Test


For counter< 5

Yes

Let percentage=1.0 PRINT marks(counter)

Let counter= counter + 1


Let counter=0

PRINT total, percentage


NO Test
For counter< 5 No

Yes
NO
Test
INPUT marks(counter) IF percentage<33

Yes

PRINT “FAIL”

Let total=total + marks(counter)

Let counter=counter+1 PRINT “PASS”

Let percentage=total*100.0/500
A Stop
Practcial No.2 (Algorithm- Marks sheet)
Step1: BEGIN
Step2: DECLARE total,counter AS integer, percentage as real
Step3:DIM marks(5) as integer
Step5: Set total=0, percentage=1.0
Step6: FOR counter=0 to 4 STEP 1
Step7: WRITE “Enter Subject [“, (counter+1),”] marks? “
Step8: READ marks[counter]
Step9: SET total= total + marks[counter]
Step10: NEXT counter
Step11: SET percentage = total * 100.0/500
Step12: FOR counter=0 to 4 STEP 1
Step13: WRITE “Subject [“, (counter+1),” = “, marks[counter]
Step14: NEXT counter
Step15: WRITE “Total= “, total, “out of 500”
Step16: WRITE “Percentage= “, percentage
Step17: IF percentage<33 THEN WRITE “FAIL” ELSE WRITE “PASS”
Step18: READ character
Step19: END
Practcial No.2 (Coding/Programming)
/* ******|PRACTICAL02:Write a program that read marks of 5 subjects, calculate the total
marks, percentage & state whether candidate is Pass or Fail.*****/

#include <stdio.h>
#include <conio.h>

int marks[5],total,counter;
float percentage;
// varible declaration.

void main(void) // main function.

{ // start of-(sof) body of main function.

clrscr();
// below code is for showing heading of the output
printf("\n\t\t ");
printf("\n\t\tThis is sample Practical No.02");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");

total=0;percentage=1.0;

for(counter=0;counter<5;counter++)
{
printf("\n\t Enter Subject [%d] marks? ",counter+1);
scanf("%d",&marks[counter]);

total+=marks[counter];
}

percentage=total*100.0/500;

for(counter=0;counter<5;counter++)
{
printf("\n\t Subject[%d] marks= %d",counter+1,marks[counter]);
}
printf("\n\n\t\tTotal= %d out of 500",total);
printf("\n\n\t\tPercentage= %.2f\n\n\t\t\t",percenta
ge);
if(percentage<33)
{printf("FAIL");} else
{printf("PASS");}
getch(); // pause screen till any button is pressed.

} // end of-(eof) body of main function.


/************************* OUTPUT *************************************

This is sample Practical No.02


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Enter Subject [1] marks? 70


Enter Subject [2] marks? 60
Enter Subject [3] marks? 80
Enter Subject [4] marks? 90
Enter Subject [5] marks? 100

Subject[1] marks= 70
Subject[2] marks= 60
Subject[3] marks= 80
Subject[4] marks= 90
Subject[5] marks= 100

Total= 400 out of 500


Percentage= 80.00

PASS
**************************************************************************/
Practcial No.3 (Flow Chart- Table of Inputted No.)
Start

INPUT makNumber

Let makMultiple=1

No
Test For
makMultiple < 12

Yes

PRINT
makNumber,”*”,makMultiple,”=”,
(makNumber*makMultiple)

Let makMultiple =
makMultiple+1

Stop
Practcial No.3 (Algorithm- Table of Inputted No.)

Step1: BEGIN
Step2: DECLARE makNumber,makMultiple as integer
Step3: WRITE “Enter any number to generate it’s table? "
Step4: READ makNumber
Step5: FOR makMultiple=1 TO 12 STEP 1
Step6: WRITE
makNumber,” *”,makMultiple,”=”,(makNumber*makMultiple)
Step7: NEXT makMultiple
Step8: READ character
Step9: END
Practcial No.3 (Coding/Programming)
/* ******|PRACTICAL03: Write program to generate the table of any inputted number
*****/

#include <stdio.h>
#include <conio.h>

int makNumber,makMultiple; // variables declaration.

void main(void) // main function.


{ // start of-(sof) body of main
function. clrscr();
// below code is for showing heading of the
output printf("\n\t\t ");
printf("\n\t\tThis is sample Practical No.02");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); printf("\n\t
Enter any number to generate it's table? ");
scanf("%d",&makNumber);

// for-loop to generate table till 12.


for(makMultiple=1;makMultiple<=12;makMultiple++)
{
printf("\n\t%d * %d = %d"makNumber,makMultiple,(makNumber*makMultiple));
}
getch(); // pause screen till any button is pressed.

} // end of-(eof) body of main function.


/************************** OUTPUT ***************************************

This is sample Practical No.03


~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter any number to generate it's table? 5
5*1=5
5 * 2 = 10
5 * 3 = 15
5 * 4 = 20
5 * 5 = 25
5 * 6 = 30
5 * 7 = 35
5 * 8 = 40
5 * 9 = 45
5 * 10 = 50
5 * 11 = 55
5 * 12 = 60
**************************************************************************/
Practcial No.4 (Flow Chart-Factorial of inputted No.)
Start

INPUT “Enter your number? ”,


num

Let factorial=1

Let counter=num

No
Test
For counter>= 1

Yes

Let factorial= factorial*Counter

PRINT “factorial of “ ,num, ”=”,


factorial

Stop
Practcial No.4 (Algorithm- Factorial of inputted No.)

Step1: BEGIN
Step2: DECLARE counter,factorial,num AS long integer
Step2: WRITE “Enter Number for Factorial? "
Step3: READ num
Step4: SET factorial=1 Step5:
SET counter=factorial
Step7: FOR counter=factorial down to 2 STEP=-1
Step8: SET factorial=factorial*counter
Step9: NEXT counter
Step10: WRITE “Factorial of”, num, “= “, factorial
Step11: END
Practcial No.4 (Coding/Programming)/*
******|PRACTICAL04: Write a program that finds the factorial of an inputted
number.*****/

#include <stdio.h>
#include <conio.h>

int inputtedNumber,factorial;

// variable declaration.

void main(void) // main function.


{ // start of-(sof) body of main
function. clrscr();
// below code is for showing heading of the
output printf("\n\t\t ");
printf("\n\t\tThis is sample Practical No.04");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~");

printf("\n\t Enter number to find it's factorial ? ");


scanf("%d",&inputtedNumber);

printf("\n\t Factorial of [%d]",inputtedNumber);


factorial=1.0;
for(inputtedNumber=inputtedNumber;inputtedNumber>=1;inputtedNumber--)
{factorial*=inputtedNumber;}
printf(" is [%d]",factorial);

getch(); // pause screen till any button is pressed.


} // end of-(eof) body of main function.
/************************ OUTPUT *************************************

This is sample Practical No.04


~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter number to find it's factorial ? 6
Factorial of [6] is [720]
***********************************************************************/
Practcial No.5 (Flow Chart- Greatest among 3 no.)
Start A

INPUT “Enter Number1? “ Test No


,mgNum1 IF mgNum2 >
mgNum3

Yes
INPUT “Enter Number2? “ PRINT mgNum2 ”is GREATEST
,mgNum2 among all three inputted”

INPUT “Enter Number3? “ PRINT mgNum3 ”is GREATEST


,mgNum3 among all three inputted”

No Test Stop
IF mgNum1 >
mgNum2

Yes
Test No
IF mgNum1 >
mgNum3

Yes
PRINT mgNum1 ”is GREATEST
among all three inputted”

PRINT mgNum3 ”is GREATEST


among all three inputted”

A
Practcial No.5 (Algorithm- Greatest among 3 no.)
Step1: BEGIN
Step2: DECLARE mgNum1, mgNum2, mgNum3 AS integer
Step3: WRITE “Enter Number1”
Step4: READ mgNum1
Step5: WRITE “Enter Number2”
Step6: READ mgNum2
Step7: WRITE “Enter Number3”
Step8: READ mgNum3
Step9: IF mgNum1> mgNum2 THEN GOTO Step10 ELSE Step14
Step10: IF mgNum1> mgNum3 THEN Step8 ELSE Step9
Step11: WRITE “number1=”, mgNum1,” is GREATEST among all
three inputted Numbers”
Step12: WRITE “number3=”, mgNum3,” is GREATEST among all
three inputted Numbers”
Step13: ENDIF rem *** eof step7 if-structure ***
Step14: IF mgNum2>mgNum3 THEN GOTO Step15 ELSE Step16
Step15: WRITE “number2=”, mgNum2,” is GREATEST among all
three inputted Numbers”
Step16: ENDIF rem *** eof step15 if-structure ***
Step17: ENDIF rem *** eof step9 if-structure ***
Step18: WRITE “number3=”, mgNum3,” is GREATEST among all
three inputted Numbers”
Step19: END
Practcial No.5 (Coding/Programming)
/* ******|PRACTICAL05: Write a program that finds out the greatest number among three
inputted numbers. *****/
#include <stdio.h>
#include <conio.h>
int mgNum1,mgNumb2,mgNum3; // variable declaration.
void main(void) // main function.
{ // start of-(sof) body of main
function. clrscr();
// below code is for showing heading of the
output printf("\n\t\t ");
printf("\n\t\tThis is sample Practical No.05");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~");
printf("\n\t Enter Number1 ? ");
scanf("%d",&mgNum1);
printf("\n\t Enter Number2 ? ");
scanf("%d",&mgNum2);
printf("\n\t Enter Number3 ? ");
scanf("%d",&mgNumb3);
if(mgNum1>mgNum2)
{ // body of outer-most if
statement. if(mgNum1>mgNumb3)
{ // body of inner if statement.
printf("\n\t\t number1=[%d] is GREATEST among all three inputted Numbers",mgNum1);
}
else
{ // else of inner if.
printf("\n\t\t number3=[%d] is GREATEST among all three inputted Numbers",mgNum3);
}
}
else if(mgNum2>=mgNum3)
{ // else-if of outer-most if statement.
printf("\n\t\t number2=[%d] is GREATEST among all three inputted Numbers",mgNum2);
}
else
{ // else of outer-most if statement.
printf("\n\t\t number3=[%d] is GREATEST among all three inputted Numbers",mgNum3);
}
getch(); // pause screen till any button is pressed.
} // end of-(eof) body of main function.
/************************ OUTPUT *************************************

This is sample Practical No.05


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter number1 ? 6
Enter number2 ? 7
Enter number3 ? 5

number2=[7] is GREATEST among all three inputted Numbers


***********************************************************************/
Practcial No.6 (Flow Chart- Calculating the Area & Volume

Start

Let constant PI as 3.14

INPUT “Enter Base of a


triangle?”,base

INPUT “Enter Height of a


triangle?”,height

Let areaOfTriangle =
(1.0/2.0)*base*height

INPUT “Enter radius of an


sphere?”, radius

Let volumeOfSphere = (4.0/3)


* pi * 3

PRINT “Area of Triangle ”,


areaofTriangle

PRINT “Volume of Sphere is “,


volumeOfSphere Stop
Practcial No.6 (Algorithm- Calculating the Area and
Volume)
Step1: BEGIN
Step2: DECLARE pi AS 3.14
Step3: DECLARE areaOfTriangle, volumeOfSphere AS Real
Number
Step4: DECLARE radius,base,height AS integer
Step5: WRITE “Enter Base of a triangle? "
Step6: READ base
Step7: WRITE “Enter Height of a triangle? "
Step8: READ height
Step9: SET areaOfTriangle= (1.0/2.0) *base*height
Step10: WRITE “Enter radius of a sphere? " Step11:
READ radius
Step12: SET volumeOfSphere= (4.0/3) * pi * 3

Step13: WRITE “Area of Triangle [base=]”, base, “height= “,


height, “] is “, areaofTriangle
Step14: WRITE “Volume of Sphere [radius= “, radius,”] is “,
volumeOfSphere
Step15: READ character
Step16: END
Practcial No.6 (Coding/Programming)/*
******|PRACTICAL06: Write a program which uses arithmetic operators to calculate the area of
triangle and volume of sphere.
area of a triangle=(1/2)Base x Height
volume of sphere=(4/3 x pi x radius x radius x radius) *****/

#include <stdio.h>
#include <conio.h>
#include <math.h>

#define pi 3.14
float areaOfTriangle,volumeOfSphere; // variable declaration.
int radius,base,height;
void main(void) // main function.
{ // start of-(sof) body of main
function. clrscr();
// below code is for showing heading of the
output printf("\n\t\t ");
printf("\n\t\tThis is sample Practical No.06");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
printf("\n\t Enter Base of a triangle? ");
scanf("%d",&base);
printf("\n\t Enter Height of a triangle? ");
scanf("%d",&height);
areaOfTriangle=(1.0/2.0*base*height);
printf("\n\t Enter radius of an sphere? ");
scanf("%d",&radius);
volumeOfSphere= 4.0/3*pi*pow(radius,3);
printf("\n\t Area of Triangle[base=%d height=%d] is %.2f",base,height,areaOfTriangle);
printf("\n\t Volume of Sphere[radius=%d] is %.2f",radius,volumeOfSphere);
getch(); // pause screen till any button is pressed.

} // end of-(eof) body of main function.


/************************ OUTPUT *************************************

This is sample Practical No.06


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter Breath of a triangle? 4
Enter Height of a triangle? 6
Enter radius of an sphere? 3
Area of Triangle[base=6 height=4] is 12.00
Volume of Sphere[radius=3] is 113.04

***********************************************************************/
Practcial No.7 (Flow Chart- Shatranjh Board)
Start A

Let mgRow=1
Let mgCol = mgCol + 1
4

5
2

No Test Let mgRow = mgRow + 1


1 For mgRow <= 8 5

Yes 1

Let mgCol=1
Stop

No Test
2 For mgCol <= 8

Yes

No Test
IF (mgRow+mgCol)
mod 2 = 0

Yes
PRINT “ “
3

PRINT “██”
3

A
Practcial No.7 (Algorithm-- Shatranjh Board)
Step1: BEGIN
Step2: DECLARE mgRow,mgColumn AS integer
Step3: FOR mgRow=1 to 8 Step=1
Step4: WRITELINE
Step5: FOR mgColumn=1 to 8 Step=1
Step6: IF (mgRow+mgColumn) Mod 2= 0 THEN WRITE “ “ ELSE
WRITE ” ██”
Step7: NEXT mgColumn
Step8: NEXT mgRow
Step9: READ character
Step10: END
Practcial No.7 (Coding/Programming)
/* ******|PRACTICAL07: Write a program to draw a check-board using if-else statement and
Nested for loops. *****/

#include <stdio.h>
#include <conio.h>
int mgRow,mgColumn; // variable declaration.

void main(void) // main function.


{ // start of-(sof) body of main
function. clrscr();
// below code is for showing heading of the
output printf("\n\t\t ");
printf("\n\t\tThis is sample Practical No.07");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
printf("\n\n"); // printf two line gap on screen.
for(mgRow=1;mgRow<=8;mgRow++)
{
printf("\n"); // printing line gap on screen.
for(mgColumn=1;mgColumn<=8;mgColumn++)
{

if((mgRow+mgColumn)%2==0)
printf(" ");
else
printf("██"); // Ascii code of █ is 219 can also be used.
} // end of for columnCounter loop.

} // end of for rowConter loop.


getch(); // pause screen till any button is pressed.
} // end of-(eof) body of main function.
/************************ OUTPUT *************************************

This is sample Practical No.07


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
█ █ █ █
█ █ █ █
█ █ █ █
█ █ █ █
***********************************************************************/
Practcial No.8 (Flow Chart- ASCII Code)

Start

Let mgAsciiCode=32

No Test For
Stop mgAsciiCode <=
127
Yes

PRINT “Character is
“,char(mgAsciiCode),” (code= “,
mgAsciiCode , ”)”

Let mgAsciiCode = mgAsciiCode


+1
Practcial No.8 (Algorithm- ASCII Code)

Step1: BEGIN
Step2: DECLARE mgAsciiCode AS integer
Step3: FOR mgAsciiCode=32 to 127 Step=1
Step4: WRITE “Character is “,char(mgAsciiCode),” (code= “,
mgAsciiCode , ”)”
Step5: READ character
Step6: END
Practcial No.8 (Coding/Programming)
/* ******|PRACTICAL08: Write a program that generate characters corresponding to ASCII
codes from 32 to 127 (using any loop). *****/

#include <stdio.h>
#include <conio.h>

int mgAsciiCode; // variable declaration.

void main(void) // main function.


{ // start of-(sof) body of main
function. clrscr();
// below code is for showing heading of the
output printf("\n\t\t ");
printf("\n\t\tThis is sample Practical No.08");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
for(mgAsciiCode=32;mgAsciiCode<=127;mgAsciiCode++)
{
printf("\tCharacter is %c(code=%d)",mgAsciiCode,mgAsciiCode);
} // end of for loop.
getch(); // pause screen till any button is pressed.
} // end of-(eof) body of main function.
/************************ OUTPUT *************************************

This is sample Practical No.08


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Character is (code=32) Character is !(Code=330 . .Character is A(code=65)
Character is B(code=66)........ Character is •(code=127)

***********************************************************************/
Practcial No.9 (Flow Chart- Printing name 10 times)

Start

INPUT “Enter your name?


”,makName

Let numOfTimes=1

Test for YES PRINT “Your name”, makName ,


numOfTimes <= “is Printed”,numOfTimes,
10 “ times”
NO

Let numOfTimes =
Stop
numOfTimes+1
Practcial No.9 (Algorithm- Print name 10 times)

Step1: BEGIN
Step2: DECLARE Dim makName(20) AS character, numOfTimes
as integer
Step3: WRITE “Enter your name? “
Step4: READ makName
Step5: FOR numOfTimes=1 to 10 Step=1
Step6: WRITE “Your Name”, makName, “is printed “,
numOfTimes, “times
Step7: READ character
Step8: END
Practcial No.9 (Coding/Programming)
/* ******|PRACTICAL09: Write a program that reads your name and prints that name 10
times using scanf() and printf() statements) *****/

#include <stdio.h>
#include <conio.h>

char name[20]; // variable declaration.


int numOfTimes;

void main(void) // main function.


{ // start of-(sof) body of main
function. clrscr();
// below code is for showing heading of the
output printf("\n\t\t ");
printf("\n\t\tThis is sample Practical No.09");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");

printf("\n\t Enter your name ? ");


scanf("%s"makName);
for(numOfTimes=1;numOfTimes<=10;numOfTimes++)
{
printf("\n\t Your Name %s is printed %d times " ,makName, numOfTimes);
}
getch(); // pause screen till any button is pressed.
} // end of-(eof) body of main function.
/************************ OUTPUT *************************************

This is sample Practical No.09


~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter Student name? Hasan

Enter Student age? 3

Enter height (5.4/6.0 etc)? 3.25

Enter Student gender(male/female)? male

Name of Student is Hasan


Age of Student is 3
Height of Student is 3.25
Gender of Student is
male
***********************************************************************/
Practcial No.10 (Flow Chart- Prime No. checking)
A
Start

INPUT "Enter Number to check PRINT “Given Number


whether is PRIME OR NOT? ", “,makNum , “ is PRIME Number "
makNum

Let flag=0 PRINT “, Hence given Number”,


makNum , “ is NOT a prime
number"

Let divisor=makNum/2
Stop

Test
1 For divisor >= 2

Test Let divisor= divisor - 1


IF makNum %
divisor = 0

Let flag=1

PRINT divisor,” absolutely divide”,


makNum “

Test
IF flag = 0

A
Practcial No.10 (Algorithm- Prime No. checking)
Step1: BEGIN
Step2: DECLARE makNum,flag, divisor as integer
Step3: WRITE" Enter Number to check whether is PRIME OR NOT?
"
Step4: READ makNum
Step5: flag=0
Step6: FOR divisor=makNum/2 to 2 STEP= -1
Step7: IF (makNum MOD divisor)= 0 THEN
Step8: SET flag=1
Step9: WRITE divisor,” absolutely divide”, makNum
Step10: GOTO Step 13
Step11: END IF
Step12: NEXT divisor
Step13: IF flag=0 THEN WRITE “ Given Number “,makNum , “ is PRIME
Number " ELSE WRITE ",Hence given Number”,
makNum , “ is NOT a prime number"
Step14: ENDIF
Step15: END
Practcial No.10 (Coding/Programming)
/* ******|PRACTICAL10: Write a program that input a number and then check it whether it is
prime or not. *****/

#include <stdio.h>
#include <conio.h>

int number,divisor,flag; // variable declaration.

void main(void) // main function.


{ // start of-(sof) body of main
function. clrscr();
// below code is for showing heading of the
output printf("\n\t\t ");
printf("\n\t\tThis is sample Practical No.10");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");

printf("\n\t Enter Number to check whether is PRIME OR NOT? ");


scanf("%d",&number);
flag=0;

for(divisor=number/2;divisor>=2;divisor--)
{
if(number%divisor==0) {flag=1;printf("%d absolutely divide %d",divisor,number); break;}
}

if(flag==0) printf("\n\t Given Number %d is PRIME number",number);


else
printf(",Hence given Number %d is NOT a prime number",number);

getch(); // pause screen till any button is pressed.


} // end of-(eof) body of main function.

/************************ OUTPUT *************************************


This is sample Practical No.10
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Enter
Number to check wheter its PRIME OR NOT? 7
Given Number 7 is PRIME number

***********************************************************************/
Practcial No.11 (Flow Chart)
Start

INPUT “Enter your name ?


”,mgName

INPUT “Enter your favorite


English alphabet?
”,makAlphabet

INPUT “Enter your age (5-100


etc)?”,age

INPUT “Enter your height


(5.4/6.0 etc)?”,height

PRINT “Your Name is”,mgName

PRINT “You like English


alphabet? ”,makAlphabet

PRINT “your are “,age,” years


old”

PRINT “and “,height ,” feet


tall.” Start
Practcial No.11 (Algorithm)

Step1: BEGIN
Step2: DECLARE mgName AS String, makAlphabet AS Character,
age AS integer, height AS Real number
Step3: WRITE “Enter your name? "
Step4: READ mgName
Step5: WRITE “Enter your favorite English alphabet?”
Step6: READ makAlphabet
Step7: WRITE “Enter your age (5-100 etc)? "
Step8: READ age
Step9: WRITE” Enter your height (5.4/6.0 etc)? " Step10:
READ height
Step11: WRITE “Your Name is”, mgName
Step12: WRITE “you like English alphabet “, makAlphabet
Step13: WRITE” you are “, age, “years old”
Step14: WRITE “and “, height, “feet tall."
Step15: END
Practcial No.11 (Coding/Programming)
/* ******|PRACTICAL11: Write a program which print a text of four lines consisting of
characters, integers value and floating point value using printf() statement and escape
sequences. . *****/

#include <stdio.h>
#include <conio.h>

char mgName[30],makAlphabet; // variable declaration.


unsigned int age;
float height;

void main(void) // main function.


{ // start of-(sof) body of main
function. clrscr();
// below code is for showing heading of the
output printf("\n\t\t ");
printf("\n\t\tThis is sample Practical No.11");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~");

printf("\n\t Enter your name? ");


gets(mgName);
printf("\n\t Enter your favorite English alphabet? ");
makAlphabet=getchar();
printf("\n\t Enter your age (5-100 etc)? ");
scanf("%u",&age);
printf("\n\t Enter your height (5.4/6.0 etc)? ");
scanf("%f",&height);

printf("\n\t Your Name is %s,",mgName);


printf("\n\t you like English alphabet %c,",makAlphabet);
printf("\n\t you are %u years old,",age);
printf("\n\t and %.2f feet tall.",height);

getch(); // pause screen till any button is pressed.


} // end of-(eof) body of main function.
/************************ OUTPUT *************************************

This is sample Practical No.11


~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Enter
your name? ABCD

Enter your favorite English alphabet? M

Enter your age (3-100 etc)? 3

Enter your height (5.4/6.0 etc)? 3.25

Your Name is ABCD,


you like English alphabet M,
you are 3 years old,
and 3.25 feet tall.
***********************************************************************/
Practcial No.12 (Flow Chart- Switch statement)
Start

Let makRow=1
3

Let makCol = makCol + 1


5
4
Test
1 For makRow <= 8 2
No
Let makRow = makRow + 1
5
Yes
Let makCol=1
1

4 Stop

No Test
2 For makCol <= 8

Yes

No Test caYsees
(makRow+makCol)
mod 2 = 0

Yes
PRINT “ “
3

PRINT “██”
3

A
Practcial No.12 (Algorithm- Switch Statement)
Step1: BEGIN
Step2: DECLARE makRow,makCol,result AS integer
Step3: FOR makRow=1 TO 8 STEP=+1
Step4: WRITELINE
Step5: FOR makCol=1 TO 8 STEP=+1
Step6: SET result=(makRow+makCol) MOD 2
Step7: IF result= 0 THEN WRITE “ “ELSE WRITE” ██”
Step8: END IF
Step9: NEXT makCol
Step10:NEXT makRow
Step11:READ character
Step12: END
Practcial No.12 (Coding/Programming)
/* ******|PRACTICAL12: Write a program, which uses Switch and break statement
.*****/

#include <stdio.h>
#include <conio.h>
int makRow,makCol,result; // variable declaration.

void main(void) // main function.


{ // start of-(sof) body of main
function. clrscr();
// below code is for showing heading of the
output printf("\n\t\t ");
printf("\n\t\tThis is sample Practical No.12");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
printf("\n\n"); // printf two line gap on screen.
for(makRow=1;makRow<=8;makRow++)
{
printf("\n"); // printing line gap on screen.
for(makCol=1;makCol<=8;makCol++)
{
result=(makRow+makCol)%2;

switch(result)
{ // start of switch(result) body.
case 0:printf(" ");break;
default:printf("%c%c",219,219); // Ascii code of █ is 219 can also be used.
} // end of switch(result)-statement.

} // end of for column loop.


} // end of for row loop.

getch(); // pause screen till any button is pressed.


} // end of-(eof) body of main function.
/************************ OUTPUT *************************************

This is sample Practical No.12


~~~~~~~~~~~~~~~~~~~~~~~~~~~~
█ █ █ █
█ █ █ █
█ █ █ █
█ █ █ █

***********************************************************************/
Practcial No.13 (Flow Chart- Pattern Printing)

Start

Let makRow=1

Test No
For makRow <=5 Stop

Yes

Let makCol=1

No Test
For makCol <= 2
makRow

Yes
PRINT “*“ Let makCol = makCol + 1

Let makRow = makRow + 1


1
Practcial No.13 (Algorithm- Pattern Printing)

Step1: BEGIN
Step2: DECLARE makRow,makCol,result AS integer
Step3: FOR makRow=1 TO 5 STEP=+1
Step4: WRITELINE
Step5: FOR makCol=1 TO makRow STEP=+1
Step6: WRITE “ * “
Step7: NEXT makCol
Step8: NEXT makRow
Step9: READ character
Step10: END
Practcial No.13 (Coding/Programming)
/* ******|PRACTICAL13: Write a program using nested for loop to print the following output
*
**
***
****
*****
**********************************************/

#include <stdio.h>
#include <conio.h>

int makRow,makCol;
; // variable declaration.

void main(void) // main function.


{ // start of-(sof) body of main
function. clrscr();
// below code is for showing heading of the
output printf("\n\t\t ");
printf("\n\t\tThis is sample Practical No.13");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
printf("\n\n"); // printf two line gap on screen.

for(makRow=1;makCol<=5;makRow++)
{
printf("\n\t\t\t"); // printing line and tab gap on screen.
for(makCol=1;makCol<=makRow;makCol++)
{
printf(" *");
} // end of for makCol loop.
} // end of for makRow loop.
getch(); // pause screen till any button is pressed.
} // end of-(eof) body of main function.

/************************ OUTPUT *************************************


This is sample Practical No.13
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
**
***
****
*****
***********************************************************************/
Practcial No.14 (Flow Chart- 2 Nos. SumFunction)

Start

INPUT “Enter number1 ?


”,number1

INPUT “Enter number2 ?


”,number2
Flow chart of Sub-process

makSum1(number1,number2)

Calling Sub-process
makSum1(number1 ,
number2)

Stop Start

Let digit1 = number1

Let digit2 = number2

PRINT ““Sum of “ , digit1 , “+”


, digit2 , “= “,(digit1+digit2)1,
“+”,digit2, “=”,(digit1+digit2)

Stop
Practcial No.14 (Algorithm- 2 Nos. SumFunction)
Step1: BEGIN
Step2: DECLARE makSum1(integer,integer) AS integer
Step3: DECLARE number1, number2 AS integer
Step4: WRITE “Enter Number1?”
Step5: READ number1
Step6: WRITE “Enter Number2?”
Step7: READ number2
Step8: Call makSum1(number1,number2)
Step9: READ character
Step10: END

Step11: BEGIN makSum1(digit1 AS integer,digit2 AS integer)


Step12: WRITE “Sum of “ , digit1 , “+” , digit2 , “= “,(digit1+digit2)
Step13: END makSum1
Practcial No.14 (Coding/Programming)
/* ******|PRACTICAL14: Write a program that input any two number and then pass these
numbers as arguments to function sum1 and then print their sum.
****************************************************************/

#include <stdio.h>
#include <conio.h>

void sum1(int,int); // function sum1 declaration.

int number1,number2; // variable declaration.

void main(void) // main function.


{ // start of-(sof) body of main
function. clrscr();
// below code is for showing heading of the
output printf("\n\t\t ");
printf("\n\t\tThis is sample Practical No.14");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
printf("\n\n"); // printf two line gap on screen.

printf("\n\t Enter Number1 ? ");


scanf("%d",&number1);

printf("\n\t Enter Number2 ? ");


scanf("%d",&number2);

sum1(number1,number2); // calling sum1 function & passing number1 & number2 to it.

getch(); // pause screen till any button is pressed.


} // end of-(eof) body of main function.

// below is the definition of function sum1.


void sum1(int digit1,int digit2)
{ // start of sum1 function body.
printf("\n\t Sum of %d + %d = %d",digit1,digit2,(digit1+digit2));
return;
} // end of sum1 function body.
/************************ OUTPUT *************************************

This is sample Practical No.14


~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter Number1 ? 7

Enter Number2 ? 6

Sum of 7 + 6 = 13
***********************************************************************/
Practcial No.15 (Flow Chart- Payroll of Emplyee)
Flow chart of Sub-process
Start
Real percentageCalculator (amount
as Real, percentage as Integer)

Input “Enter Basic Pay?


”,mgBasicPay
Start

Let medicalAllowance =
RETURN percentageCalculator(mgB
(amount*percent/100.0) AS asicPay, 25)
Real number

Let conveyanceAllowance=
percentageCalculator(mgB
asicPay, 20)
Stop

Let houseRent =
percentageCalculator(mgB
asicPay, 45)

Let gpFund =
percentageCalculator(mgB
asicPay, 7)

Let grossPay = mgBasicPay+


medicalAllowance +
ConveyanceAllowance + houseRent

Let netPay = grossPay - gpFund

AAA
AAA

PRINT “ BASIC PAY=


“,mgBasicPay

PRINT “ MEDICAL ALLOWANCE=


,medicalAllowance

PRINT “Conveyance Allowance=


“,conveyanceAllowance

PRINT “ House Rent=


“,houseRent

PRINT “ Gross Pay=


“,grossPay

PRINT “ Deduction of GPFund=


“,gpFund

PRINT “ Net Pay= “,netPay

Stop
Practcial No.15 (Algorithm- Payroll of Employee)
Step1: BEGIN
Step2: DECLARE percentageCalculator(Realnumber, integer) AS
Real Number
Step3: DECLARE mgBasicPay, medicalAllowance,
conveyanceAllowance, houseRent, gpFund, grossPay, netPay AS
Real Number
Step4: WRITE “Enter Basic Pay? “
Step5: READ mgBasicPay
Step6: SET medicalAllowance=CALL
percentageCalculator(mgBasicPay,25)
Step7: SET conveyanceAllowance = CALL
percentageCalculator(mgBasicPay,20)
Step8: SET houseRent = CALL percentageCalculator(mgBasicPay,45)
Step9: SET gpFund = CALL percentageCalculator(mgBasicPay,7)
Step10: SET grossPay= mgBasicPay + medicalAllowance +
conveyanceAllowance + houseRent
Step11: SET netPay= grossPay-gpFund
Step12: WRITE “BASIC PAY= “, mgBasicPay
Step13: WRITE “MEDICAL ALLOWANCE= “, medicalAllowance
Step14: WRITE “Conveyance Allowance= “, conveyanceAllowance
Step15: WRITE “House Rent= “, houseRent
Step16: WRITE “Gross Pay= “, grossPay
Step17: WRITE “Deduction of GPFund= “, gpFund
Step18: WRITE “Net Pay= “, netPay
Step19: READ character
Step20: END
Step21: BEGIN FUNCTION percentageCalculator(amount AS Real
Number,percent AS integer)
Step22: RETURN (amount*percent/100.0)
Step23: END FUNCTION percentageCalculator
Practcial No.15 (Coding/Programming)
/* ******|PRACTICAL15: Write a program to calculate a pay roll of employees. Read the
Basic pay from key board. Calculate medical allowance as 25% of basic pay, conveyance

allowance as 20% and house rent 45 % of basic pay and deduction of GP fund 7% of basic
pay

. Calculate g r o s s pay and net pay.


****************************************************************/

#include <stdio.h>
#include <conio.h>

float percentageCalculator(float,int); // function sum1 declaration.

float mgBasicPay,medicalAllowance,conveyanceAllowance,houseRent,gpFund,grossPay,netPay;

// variable declaration.

void main(void) // main function.


{ // start of-(sof) body of main
function. clrscr();
// below code is for showing heading of the
output printf("\n\t\t ");
printf("\n\t\tThis is sample Practical No.15");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
printf("\n\n"); // printf two line gap on screen.

printf("\n\t Enter Basic Pay ? ");


scanf("%f",&mgBasicPay);

// calling percentageCalculator function & passing values to it.

medicalAllowance=percentageCalculator(mgBasicPay,25);
conveyanceAllowance=percentageCalculator(mgBasicPay,20);
houseRent=percentageCalculator(mgBasicPay,45);
gpFund=percentageCalculator(mgBasicPay,7);

grossPay=mgBasicPay+medicalAllowance+conveyanceAllowance+houseRent;
netPay=grossPay-gpFund;

printf("\n\t BASIC PAY= %.2f",mgBasicPay);


printf("\n\t MEDICAL ALLOWANCE= %.2f",medicalAllowance);
printf("\n\t Conveyance Allowance= %.2f",conveyanceAllowance);

printf("\n\t House Rent= %.2f",houseRent);

printf("\n\t Gross Pay= %.2f",grossPay);


printf("\n\t Deduction of GPFund= %.2f",gpFund);

printf("\n\t Net Pay= %.2f",netPay);

getch(); // pause screen till any button is pressed.


} // end of-(eof) body of main function.

// below is the definition of percentageCalculator function.


float percentageCalculator(float amount,int percent)
{ // start of function
body. return (amount*percent/100.0);
} // end of function body.
/************************ OUTPUT *************************************

This is sample Practical No.15


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter Basic Pay ? 1000

BASIC PAY= 1000.00


MEDICAL ALLOWANCE= 250.00
Conveyance Allowance= 200.00
House Rent= 450.00
Gross Pay= 1900.00 Deduction
of GPFund= 70.00 Net Pay=
1830.00
***********************************************************************/

You might also like