0% found this document useful (0 votes)
21 views22 pages

Practical Papers

The document contains a series of practical programming exercises in C language, including tasks such as swapping variables, calculating student pass/fail based on percentage, printing patterns using nested loops, and converting measurements. Additionally, it includes HTML exercises for creating basic web pages with various elements like headings, paragraphs, and font styles. Each practical exercise is accompanied by a solution code snippet.

Uploaded by

parvaizgopang66
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)
21 views22 pages

Practical Papers

The document contains a series of practical programming exercises in C language, including tasks such as swapping variables, calculating student pass/fail based on percentage, printing patterns using nested loops, and converting measurements. Additionally, it includes HTML exercises for creating basic web pages with various elements like headings, paragraphs, and font styles. Each practical exercise is accompanied by a solution code snippet.

Uploaded by

parvaizgopang66
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/ 22

CamScanner

CamScanner
CamScanner
CamScanner
CamScanner
CamScanner
CamScanner
CamScanner
CamScanner
Practical #1

Write a program that swaps the values of two integer variables without help
of any third variable.

Solution

#include<stdio.h>
#include<conio.h>
main()
{
int x,y;
printf("Enter First number=");
scanf("%d",&x);
printf("Enter Second number=");
scanf("%d",&y);
x=x+y;
y=x-y;
x=x-y;
printf("Numbers after swaping x= %d y= %d",x,y);
getch();
}
Practical #2

Write a program in c language that take the percentage of student as an input


and display pass if the percentage is above 50.

Solution

#include<stdio.h>
#include<conio.h>
main()
{
int n;
printf("Enter Percentage of student=");
scanf("%d",&n);
if(n>50)
printf("Pass");
getch();
}

Practical #3

Write a program to print the output as shown below using while nested loop.
*
Solution **
#include<stdio.h> ***
#include<conio.h> ****
*****
int main()
{
int i=1,j;
while(i<=5)
{
j=1;
while(j<=i)
{
printf("*");
j++;
}
printf("\n");
i++;
}
getch();
}

Practical #4

Write a program in c language that print your name and name of your school
on screen using printf function.

Solution

#include<stdio.h>
#include<conio.h>
main()
{
printf("Name: Rahil Asghar \n");
printf("School: GHS Amin Garh RYK");
getch();
}
Practical #5

Write a program to print the output as shown below using while nested loop.
*****
Solution
****
#include<stdio.h> ***
#include<conio.h> **
int main() *
{
int i=5,j;
while(i>=1)
{
j=1;
while(j<=i)
{
printf("*");
j++;
}
printf("\n");
i--;
}
getch();
}
Practical #6

Write a program in c language that print your age in years to a variable and
find the age in month and days.

Solution

#include<stdio.h>
#include<conio.h>
int main()
{
int age,d,m;
printf("Enter Your Age in Year=");
scanf("%d",&age);
m=age*12;
d=age*365;
printf("\nYour Age in Years= %d\n",age);
printf("Your Age in Months= %d\n",m);
printf("Your Age in Days= %d",d);
getch();
}

Practical #7

Write a program to print the output as shown below using while nested loop.
12345
Solution 1234
#include<stdio.h> 123
#include<conio.h> 12
1
int main()
{
int i=5,j;
while(i>=1)
{
j=1;
while(j<=i)
{
printf("%d ",j);
j++;
}
printf("\n");
i--;
}
getch();
}
Practical #8

Write a program in c language that convert millimeters into inches and print
the result on to clean using assignment statement in the program.

Solution
#include<stdio.h>
#include<conio.h>
int main()
{
float mm,in;
printf("Enter milimeters=");
scanf("%f",&mm);
in=mm/25.4;
printf("Result in inches=%f",in);
getch();
}
Practical #9

Write a program to print the output as shown below using while nested loop.
1
Solution
12
#include<stdio.h> 123
#include<conio.h> 1234
12345
int main()
{
int i=1,j;
while(i<=5)
{
j=1;
while(j<=i)
{
printf("%d ",j);
j++;
}
printf("\n");
i++;
}
getch();
}
Practical #10

Write a program in c language that interchange value of the two variables


using assignment statement and print the exchanged value on screen.

Solution
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c;
printf("Enter first number=");
scanf("%d",&a);
printf("\nEnter second number=");
scanf("%d",&b);
c=a;
a=b;
b=c;
printf("value after swapping a=%d b=%d",a,b);
getch();
}
Practical #11

Write a program to print the output as shown below using while nested loop.
1 4 9 16 25
Solution 1 4 9 16
#include<stdio.h> 1 4 9
#include<conio.h> 1 4
int main() 1
{
int i=5,j;
while(i>=1)
{
j=1;
while(j<=i)
{
printf("%d ",j*j);
j++;
}
printf("\n");
i--;
}
getch();
}
Practical #12

Write a program in c language that print text of four lines consisting of


integer value character floating value and string.

Solution
#include<stdio.h>
#include<conio.h>
main()
{
int i=10;
float f=25.9;
char c='A';
char s[]="Pakistan";
printf("Integer value: %d\n",i);
printf("Float value: %f\n",f);
printf("Character value: %c\n",c);
printf("String value: %s\n",s);
getch();
}
Practical #13

Write a program to print the output as shown below using while nested loop.
1
Solution 1 4
#include<stdio.h> 1 4 9
#include<conio.h> 1 4 9 16
int main() 1 4 9 16 25
{
int i=1,j;
while(i<=5)
{
j=1;
while(j<=i)
{
printf("%d ",j*j);
j++;
}
printf("\n");
i++;
}
getch();
}
Practical #14

Write a program in c language that find the square and cube of a number and
print on screen.

Solution
#include<stdio.h>
#include<conio.h>
int main()
{
int n;
printf("Enter a number=");
scanf("%d",&n);
printf("Squar of Number is=%d",n*n);
printf("\nCube of Number is=%d",n*n*n);
getch();
}
Practical #15

Write a program to print the output as shown below using while nested loop.
1 2 3 4 5
Solution
1 2 3 4 5
#include<stdio.h>
#include<conio.h> 1 2 3 4 5
int main() 1 2 3 4 5
{ 1 2 3 4 5
int i=1,j;
while(i<=5)
{
j=1;
while(j<=5)
{
printf("%d ",j);
j++;
}
printf("\n");
i++;
}
getch();
}
Practical #16

Write a program in c language that compute and print the area of a square.

Solution
#include<stdio.h>
#include<conio.h>
int main()
{
int s;
printf("Enter Side of square=");
scanf("%d",&s);
printf("Area of square is=%d",s*s);
getch();
}
Practical #17

Write a program to print the output as shown below using while nested loop.
1
Solution
2 1
#include<stdio.h>
#include<conio.h> 3 2 1
main() 4 3 2 1
5 4 3 2 1
{
int i=1,j;
while(i<=5)
{
j=i;
int sp=5-i;
while(sp>0)
{
printf(" ");
sp--;
}
while(j>0)
{
printf("%d ",j);
j--;
}
printf("\n");
i++;
}
getch();
}
Practical #18

Write a program in c language that converts 25.9 centigrade temperature into


Fahrenheit and print on console using the formula.
Solution
#include<stdio.h>
#include<conio.h>
main()
{
float c=25.9;
float f;
f=(9.0/5.0)*c+32;
printf("Temperature in Fahrenheit: %f ",f);
getch();
}
Practical #19

Draw a flow chart to find the volume of cube.


Practical #20

Draw a flow chart to find the sum and average of three numbers.

Practical #21

Draw a flow chart to input a number and display whether it is even or odd.
Practical #22

Draw a flow chart to print even numbers from 1 to 10.

Practical #23

Draw a flow chart to find the factorial of a given number.


Practical #24

Draw a flow chart to find the area of parallelogram.

Practical #25

Draw a flow chart to convert temperature from Fahrenheit to centigrade.


Practical #26

Draw a flow chart to convert temperature from centigrade to Fahrenheit.

Practical #27

Draw a flow chart to convert an ASCII code in to corresponding character.


Practical #28

Create an HTML page which has head and body tags.

<!DOCTYPE html>
<html>
<head>

</head>
<body>
</body>
</html>
Practical #29

Create an HTML page which has additional tags of title, paragraph and line
break.

<!DOCTYPE html>
<html>
<head>
<title>Welcome!</title>

</head>
<body>
<p> Hello</p>
</br>
<p> Good bye</p>
</body>
</html>
Practical #30

Create an HTML page which the additional function of headings up to two


levels, Bold.

<!DOCTYPE html>
<html>
<head>
<title>Welcome!</title>

</head>
<body>
<h1> Heading 1</h1>
<h2> Heading 2</h2>
<p><b>This is Bold</b></p>
</body>
</html>
Practical #31

Create an HTML page which the additional function of font face.

<!DOCTYPE html>
<html>
<head>
<title>Welcome!</title>

</head>
<body>
<p><font face="Arial black"> This is Arial Black font face</font></p>
</body>
</html>
Practical #32

Create an HTML page which the additional function of font size.


<!DOCTYPE html>
<html>
<head>
<title>Welcome!</title>

</head>
<body>
<p><font size="20"> The size of font is set as 20</font></p>
</body>
</html>
Practical #33

Create an HTML page which the additional function of headings up to two


levels, Underline.

<!DOCTYPE html>
<html>
<head>
<title>Welcome!</title>

</head>
<body>
<h1> Heading 1</h1>
<h2> Heading 2</h2>
<p><u>This is Uderline</u></p>
</body>
</html>
Practical #34
Create an HTML page which the additional function of headings up to two
levels, Italic.
<!DOCTYPE html>
<html>
<head>
<title>Welcome!</title>

</head>
<body>
<h1> Heading 1</h1>
<h2> Heading 2</h2>
<p><i>This is italic</i></p>
</body>
</html>
Practical #35

Create an HTML page which the additional function of font color.

<!DOCTYPE html>
<html>
<head>
<title>Welcome!</title>

</head>
<body>
<p><font color="blue"> The colour of font is set as blue</font></p>
</body>
</html>

You might also like