CPL Lab Manual
CPL Lab Manual
LIST OF EXPERIMENTS:
AIM:
To create a document and manipulate the text with specific notations using MS-office.
PROCEDURE :
1. Open a new document using File → New option and type text.
2. For justification, select the entire text in the document then press CTRL+J or select the justify
button on the formatting toolbar.
3. For bold facing, select the particular word then press CTRL +B or select the B on the
formatting toolbar.
4. To make Italic style, select the particular word then press CTRL +I or select the I on the
formatting toolbar.
5. For Underlining , select the particular word then press CTRL +U or select the U on the
formatting toolbar.
6. For spelling corrections, select the particular word, then right click the mouse or click spelling
and grammar button on the standard tool bar.
7. For saving the document, press CTRL+S or click on save button on standard tool bar or select
the save option from the File menu.
The above options are commonly used for creating the document. Apart from these, MS
WORD provides a lot of options for making the document an attractive one.
RESUME
Raghul. V
4/10,Nehru Street, e-mail id : [email protected]
Salem-10. Mobile No.: 9876543210
OBJECTIVE:
To obtain a meaningful and challenging position which will enables me to become a
recognized employee, face the challenges, serve the industry with all my might and to learn and
acquire more practical knowledge.
EDUCATIONAL QUALIFICATION:
M.E. Computer Science with 8.6 CGPA in V.S.B. Engineering College,Karur.
B.E. Computer Science with an aggregate of 73% from V.S.B. Engineering College,
Karur.
HSC 2006, with an aggregate of 68% from Cheran school, Karur
SSLC 2004, with an aggregate of 72% from Cheran school, Karur
SOFTWARE SKILLS:
AREA OF INTEREST:
Data Structure
Computer Networks
PERSONAL DETAILS:
NAME : Raghul.V
FATHER’S NAME : Vishnu.R
DATE OF BIRTH : 06-03-1988
COMMUNICATION
ADDRESS : 4/10,Nehru Street,
Salem-10.
DECLARATION
I hereby declare that the above details are true to the best of my knowledge.
Yours
Raghul.V
PROCEDURE:
x y
2. + =1
a b
3. x 2+ y 2+ z 2 +2 x−4 y+ 2 z−3=0
4. h [ γ −γ 1 ] =0
sin( A + D)/2
5. μ=
sin A /2
1
6. σ =
ρ
RESULT:
Thus, the given document has been created and manipulated using MS-office.
EX.NO:02 PRESENTATION AND VISUALIZATION – GRAPHS AND CHARTS
AIM:
To prepare the Line, XY, Bar and Pie Charts in MS-Excel.
Create examination databases and find the total and average of each student.
RULES:
PROCEDURE:
AIM:
To draw a flowchart using drawing toolbar in MS-WORD.
PROCEDURE :
1. Choose flowchart options in the auto shapes menu of the Drawing Toolbar.
2. Choose the appropriate flowchart symbol and then drag the symbol in the document.
3. Type the text in the symbol, by right click then choose Add Text.
4. Using the Arrow button, Line style button and Arrow Style in the Drawing Toolbar the lines
onnecting to the different flowchart symbols.
5. Select all the flowchart symbols and lines in the document using the Select Objects button,
then right choose Grouping, then click on Group.
6. Now all the Flowchart symbols are grouped into one.
SAMPLE FLOWCHART:
start
Start
Read a,b
Read a,b
No
yes If a>b
Read a Read b
Stop
EX:NO:4(a) INTEGER TO FLOAT CONVERSION
AIM:
To write a c program to convert a value of one data type into another data type.
ALGORITHM:
Step1:Start
Step 2: Declare the necessary variables a and b as integer and float.
Step 3: Read the input of the integer a.
Step 4: Assign the value of the integer to a float variable and a double
variable.
Step 5: Display the value of the float variable and the double variable.
Step6:Stop.
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
float b;
int a;
clrscr();
printf("\n enter an integer\n");
scanf("%d",&a);
b=(float)a;
printf("\n the converted float value is %f",b);
getch();
}
OUTPUT:
EX:NO:4(b) AREA OF A TRIANGLE
Date:
AIM:
To write a program in C to find the area of a given triangle of sidesa,b,c.
ALGORITHM:
Step1: Start
Step2: read the input values of sides of a triangle a,b,c
Step3: compute s=(a+b+c)/2
Step4: compute d=(s*(s-a)*(s-b)*(s-c))
Step5: compute the area of triangle area=sqrt(d)
Step6: print area
Step7: Stop
PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a,b,c;
float s,d,area;
clrscr();
printf("enter three sides:");
scanf("%d%d%d,&a,&b,&c");
s=(a+b+c)/2;
d=(s*(s-a)*(s-b)*(s-c));
area=sqrt(d);
printf("area of triangle=%f sq units \n",area);
getch();
}
OUTPUT:
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int num=1234567890;
float dec=0.123456;
double ext=0.123456789;
char ltr='A';
clrscr();
printf("size of num int is %d bytes\n",sizeof num);
printf("size of dec float is %d bytes\n",sizeof dec);
printf("size of ext double is %d bytes\n",sizeof ext);
printf("size of ltr char is %d bytes\n",sizeof ltr);
getch();
}
OUTPUT:
AIM:
Write a program in C to coversion of celcius into Fahrenheit and .
ALGORITHM:
Step1: Start
Step2: Read the Celsius value
Step3: Calculate the fahrenhiet value by using the formula f=(1.8*c)+32
Step4: Print the fahrenhiet value
Step5: Read the fahrenhiet value
Step6: Calculate the Celsius value by using the formula c=(f-32)/1.8
Step7: Print the Celsius value
Step8: Stop
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
float c,f;
//float a,b;
clrscr();
printf("\n\nEnter the value of temp in Celcius\n");
scanf("%f",&c);
f=(1.8*c)+32;
printf("\nThe equivalent farenhiet value is%f\n",f);
printf("\nEnter the value of temp in Farenhiet");
scanf("%f",&f);
c=(f-32)/1.8;
printf("\nThe equivalent celcius value is%f\n",c);
getch();
}
OUTPUT:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("\nEnter the value of a & b\n");
scanf("%d%d",&a,&b);
a=a+b;
b=a-b;
a=a-b;
printf("The values of a & b after swapping are \n%d\n%d",a,b);
getch();
}
OUTPUT:
Result:
Thus the above programs was written and executed successfully.
ALGORITHM:
OUTPUT:
EX:NO:5(b) ARITHMETIC CALCULATOR
AIM:
To write a menu driven c program to implement an Arithmetic Calculator.
ALGORITHM:
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,ch;
float c;
clrscr();
printf("\n enter the number:\n");
scanf("%d",&a);
printf("\n enter the number:\n");
scanf("%d",&b);
printf("\n 1. add \n 2. subtract \n 3. multiply \n 4. divide \n");
printf("\n enter the choice:\n");
scanf("%d",&ch);
switch(ch)
{
case 1:
c=a+b;
printf("\nThe addition of two numers are%f",c);
break;
case 2:
c=a-b;
printf("\nThe difference b/w two nos are %f",c);
break;
case 3:
c=a*b;
printf("\nThe multiplication of two nos are%f",c);
break;
case 4:
c=a/b;
printf("\nthe division is%f",c);
break;
}
getch();
}
OUTPUT:
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,d;
clrscr();
printf("enter the number");
scanf("%d",&a);
b=a;
c=0;
while(a>0)
{
d=a%10;
c=c+(d*d*d);
a=a/10;
}
if(b==c)
printf("%d is an armstrong number",b);
else
printf("%d is not an armstrong number",b);
getch();
}
OUTPUT:
EX:NO:5(d) BIGGEST OF 3 NUMBERS
AIM:
To write a c program to examine the biggest of given three numbers.
ALGORITHM:
Step 1: Declare three integer variables
Step 2: Read the 3 inputs
Step 3: Compare first two numbers and go to Step4
Step 4: If first number is greater than second number then compare first
number with third number else go to step 6
Step 5: If first number is greater than third number print first number as
biggest number else print third number as biggest
Step 6: Compare second number with third number
Step 7: If second number is greater than third number print second number
as biggest number else print third number as biggest
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("enter 3 numbers\n");
scanf("%d%d%d",&a,&b,&c);
if(a>b)
{
if(a>c)
{
printf("the first nummber %d is biggest\n",a);
}
}
else if(b>c)
{
printf("the second number %d is biggest\n",b);
}
else
printf("the third number %d is biggest\n",c);
getch();
}
OUTPUT:
EX:NO:5(e) FACTORIAL OF THE GIVEN NUMBER
AIM:
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int fact=1,i,num;
clrscr();
printf("enter the number");
scanf("%d",&num);
for(i=1;i<=num;i++)
{
fact=fact*i;
}
printf("the factorial is %d",fact);
getch();
}
OUTPUT:
AIM:
To write a c program to find the sum of “N‟ natural numbers for given range.
ALGORITHM:
Step 1: Initialize the sum as 0
Step 2: Read the range as input
Step 3: Initialize a counter with 1
Step 4: Overwrite the sum by adding counter value & sum
Step 5: Increment the counter value by 1
Step 6: Repeat the steps 4 & 5 until the counter is less than or equal to range
Step 7: Print the sum
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,sum=0;
clrscr();
printf("enter the range\n");
scanf("%d",&n);
i=1;
while(i<=n)
{
sum=sum+i;
i++;
}
printf("\n the sum of first %d numbers is %d\n",n,sum);
getch();
}
OUTPUT:
EX:NO:5(g) SUM OF DIGITS
AIM:
To write a c program to find the sum of digits for a given number.
ALGORITHM:
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,sum=0;
clrscr();
printf("enter a number\n");
scanf("%d",&n);
do
{
i=n%10;
sum=sum+i;
n=n/10;
}
while(n>0);
printf("the sum of digit is %d\n",sum);
getch();
}
OUTPUT:
EX:NO:5(h) NUMBER CHECKING
AIM:
To write a menu driven c program to check whether the given number is Palindrome,
Armstrong and Prime.
ALGORITHM:
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,i,sum=0,n,ch,m;
clrscr();
printf("\n enter a number\n");
scanf("%d",&a);
printf("\n 1.palindrome\n 2.Armstrong\n 3.prime\n");
printf("\n enter the choice:\n");
scanf("%d",&ch);
switch(ch)
{
case 1:
n=a;
while(a>0)
{
i=a%10;
sum=(sum*10)+i;
a=a/10;
}
if(n==sum)
printf("given number is palindrome\n");
else
printf("given number is not palindrome\n");
break;
case 2:
n=a;
do
{
i=a%10;
sum=sum+(i*i*i);
a=a/10;
}while(a>0);
if(n==sum)
printf("given number is armstrong\n");
else
printf("given number is not armstrong\n");
break;
case 3:
m=5;
n=sqrt(a);
for(i=2;i<=n;i++)
{
if(a%i==0)
{
m=0;
break;
}
}
if(m==0)
printf("given number is prime\n");
else
printf("given number is not prime\n");
break;
}
getch();
}
OUTPUT:
Result:
Thus the above programs was written and executed successfully.
SIMPLE PROGRAMMING FOR ONE DIMENSIONAL AND TWO
DIMENSIONAL ARRAYS
EX:NO:6(a) LARGEST AND SMALLEST ELEMENT OF THE GIVEN ARRAY
AIM:
To write a program to find the largest and smallest of the given array.
ALGORITHM:
#include<stdio.h>
#include<conio.h>
Void main()
{
int a[100],i,small,large,no;
clrscr();
printf(“In how many numbers you want to find....”);
scanf(“%d”,&no);
printf(“Enter the elements of the array....”);
for(i=0;i<no;i++)
scanf(“%d”,&a[i]);
printf(“\nThe elements of the array “);
for(i=0;i<no;i++)
printf(“\n%d”,a[i]);
small=a[0];
large=a[0];
for(i=1;i<no;i+
+)
{
if(a[i]>large)
large=a[i];
else if(a[i]<small)
small=a[i];
}
printf(“\nThe largest of the given array is %d”,large);
printf(“\nThe smallest of the given array is %d”,small);
getch();
}
OUTPUT:
AIM:
To write a program to give the addition of two matrixes.
ALGORITHM:
Step-1 Start the program
Step-2 Enter the row and column of the matrix
Step-3 Enter the elements of the A matrix
Step-4 Enter the elements of the B atrix Step-5
Print the A matrix in the matrix form
Step-6 Print the B matrix in the matrix form
Step-7 Set a loop up to the row
Step-8 Set a inner loop up to the column
Step-9 Add the elements of A and B in column wise and store the result
in C matrix
Step-10 After the execution of the two loops. Print the value of C
matrix
Step-11 Stop
PROGRAM:
#include<stdio.h>
#include<conio.h>
Void main()
{
int a[25][25],b[25][25],c[25][25],i,j,m,n;
printf(“Enter the rows and column of two matrixes...\n”);
scanf(“%d %d”,&m,&n);
printf(“\nEnter the elements of A matrix...”);
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
scanf(“%d”,&a[i][j]);
}
printf(“\nEnter the elements of B matrix...”);
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
scanf(“%d”,&b[i][j]);
}
printf(“\nThe elements of A matrix”);
for(i=0;i<m;i++)
{
printf(“\n”);
for(j=0;j<n;j++)
printf(“\t%d”,a[i][j]);
}
printf(“\nThe elements of B matrix”);
for(i=0;i<m;i++)
{
printf(“\n”);
for(j=0;j<n;j++)
printf(“\t%d”,b[i][j]);
}
printf(“\nThe addition of two matrixes”);
for(i=0;i<m;i++)
{
printf(“\n”);
for(j=0;j<n;j++)
{
c[i][j]=a[i][j]+b[i][j];
printf(“\t%d”,c[i][j]);
}}
}
OUTPUT:
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],sum,b[3][3],c[3][3],i,j,k;
clrscr();
printf("enter the 1st matrix");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("enter the 2nd matrix");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
scanf("%d",&b[i][j]);
}
}
printf("\n the 1st matrix is:\n");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
printf("%d\t",a[i][j]);
}
printf("\n");
}
printf("\n the 2nd matrix is:\n");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
printf("%d\t",b[i][j]);
}
printf("\n");
}
printf("the multiplication of two matrix is:");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
sum=0;
for(k=0;k<=2;k++)
{
sum=sum+a[i][k]*b[k][j];
c[i][j]=sum;
}
}
}
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
printf("%d\t",c[i][j]);
}
printf("\n");
}
getch();
}
OUTPUT:
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],b[3][3],c[3][3],i,j;
clrscr();
printf("enter the 1st matrix");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("enter the 2nd matrix");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
scanf("%d",&b[i][j]);
}
}
printf("\n the 1st matrix is:\n");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
printf("%d\t",a[i][j]);
}
printf("\n");
}
printf("\n the 2nd matrix is:\n");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
printf("%d\t",b[i][j]);
}
printf("\n");
}
printf("the sum of two matrix is:");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
c[i][j]=a[i][j]+b[i][j];
}
}
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
printf("%d\t",c[i][j]);
}
printf("\n");
}
getch();
}
OUTPUT:
Result:
Thus the above programs was written and executed successfully.
SOLVING PROBLEMS USING STRING FUNCTIONS
ALGORITHM:
PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char s[20],s1[20];
clrscr();
printf("enter a string\n");
scanf("%s",s);
strcpy(s1,s);
strrev(s1);
if(strcmp(s,s1)==0)
printf("the given string is palindrome\n");
else
printf("the given string is not palindrome\n");
getch();
}
OUTPUT:
OUTPUT:
EX:NO:7(c) COPY THE STRING
AIM:
To write a C program to copy the strings using strcpy()
ALGORITHM:
OUTPUT:
EX:NO:7(e) STRING CONCATENATION
AIM:
To write a c program to find the length of given two strings and concatenate
them
ALGORITHM:
PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char s[20],s1[20];
clrscr();
printf("enter a 1st string\n");
scanf("%s",s);
printf("enter a 2nd string\n");
scanf("%s",s1);
strcat(s,s1);
printf("the concatenated string is\n%s",&s);
getch();
}
OUTPUT:
Result:
Thus the above programs was written and executed successfully.
PROGRAMS WITH USER DEFINED FUNCTIONS
AIM:
To write a c program to check whether the given year is leap or not using functions.
ALGORITHM:
PROGRAM:
#include<stdio.h>
#include<conio.h>
void is_leap()
{
int yr;
clrscr();
printf("enter a year\n");
scanf("%d",&yr);
if(yr%4==0)
printf("given year is leap year");
else
printf("given year is not a leap year");
getch();
}
main()
{
is_leap();
}
OUTPUT:
EX: NO: 08 (b) FUNCTIONS WITHOUT ARGUMENTS & WITH RETURN TYPE
AIM:
To write a c program to calculate the area of triangle using functions.
ALGORITHM:
PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<math.h>
float area()
{
int a,b,c;
float s,r;
clrscr();
printf("enter 3 sides\n");
scanf("%d%d%d",&a,&b,&c);
s=(a+b+c)/2;
r=sqrt(s*(s-a)*(s-b)*(s-c));
return r;
}
main()
{
float a;
a=area();
printf("the area of triangle is%f\n",a);
getch();
}
OUTPUT:
EX: NO: 08 (c) FUNCTIONS WITH ARGUMENTS & WITHOUT RETURN TYPE
AIM:
To write a c program to sort the given array of elements using functions.
ALGORITHM:
PROGRAM:
#include<stdio.h>
#include<conio.h>
void sorting(int a[],int n)
{
int i,j,t;
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
printf("array elements before sorting\n");
for(i=0;i<n;i++)
printf("%d\t",a[i]);
}
main()
{
int i,a[10],n;
clrscr();
printf("enter total no.of elements\n");
scanf("%d",&n);
printf("enter array elements one by one\n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("array elemets before sorting\n");
for(i=0;i<n;i++)
printf("%d\t",a[i]);
printf("\n");
sorting(a,n);
getch();
}
OUTPUT:
EX: NO: 08 (d) FUNCTIONS WITH ARGUMENTS & RETURN TYPE
AIM:
To write a c program to find the smallest element of given array of elements
using functions.
ALGORITHM:
PROGRAM:
#include<stdio.h>
#include<conio.h>
int small(int a[],int n)
{
int s,i;
s=a[0];
for(i=0;i<n;i++)
{
if(a[i]<s)
s=a[i];
}
return s;
}
main()
{
int i,a[10],n,s;
clrscr();
printf("enter total no of elements\n");
scanf("%d",&n);
printf("enter array elements one by one\n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("array elements:\n");
for(i=0;i<n;i++)
printf("%d\t",a[i]);
printf("\n");
s=small(a,n);
printf("the smallest element of given array is%d",s);
getch();
}
OUTPUT:
Result:
Thus the above programs was written and executed successfully.
EX.NO:9(a) RECURSIVE FUNCTIONS –FACTORIAL OF A NUMBER
AI M:
To write a C program to find the factorial of a given number
ALGORITHM:
PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int num,a;
clrscr();
printf("enter the number");
scanf("%d",&num);
a=recur(num);
printf("the factorial of the number %d is %d",num,a);
getch();
}
recur(int no)
{
int fact=1;
if(no==1)
return(1);
else
fact=no*recur(no-1);
return fact;
}
OUTPUT:
EX:NO:9(b) FIBONACCI SERIES
AIM:
To write a program in C to print the Fibonacci series.
ALGORITHM:
Step-1: Start
Step-2: Read the input variable ‘n’
Step-3: Call function fib(n)
Step-4: Stop.
FUNCTION:
Step-1: a=0,b=1
Step-2: print a, b
Step-3: for(i=0;i<n;i++)
Step-3-1: c=a+b
Step-3-2: a=b
Step-3-3: b=a
Step-3-4: print c
Step-4: stop
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,n;
clrscr();
printf("enter the fibonacci series limit\n");
scanf("%d",&n);
fib(n);
getch();
}
int fib(int n)
{
int a,b,c,i;
a=0;
b=1;
printf("\n fibonacci series\n");
printf("\n%d\n%d",a,b);
for(i=0;i<n;i++)
{
c=a+b;
a=b;
b=c;
printf("\n%d",c);
}
return 0;
}
OUTPUT:
Result:
Thus the above programs was written and executed successfully.
EX:NO:10(a) PROGRAM USING STRUCTURES AND UNIONS
STUDENT STRUCTURE
PROGRAM:
#include<stdio.h>
#include<conio.h>
struct student
{
char name[10];
int rollno,m1,m2,m3,total;
};
void main()
{
int num,i,j;
struct student s1[10];
clrscr();
printf("enter the no of students\n");
scanf("%d",&num);
for(i=0;i<num;i++)
{
printf("enter the roll number");
scanf("%d",&s1[i].rollno);
printf("enter the name");
scanf("%s",&s1[i].name);
printf("enter the mark1");
scanf("%d",&s1[i].m1);
printf("enter the mark2");
scanf("%d",&s1[i].m2);
printf("enter the mark3");
scanf("%d",&s1[i].m3);
s1[i].total=s1[i].m1+s1[i].m2+s1[i].m3;
}
printf("\n the details of the mark list is as follows\n");
printf("\n roll no");
printf("\t name");
printf("\t mark1");
printf("\t mark2");
printf("\t mark3");
printf("\t total");
printf("\n");
for(i=0;i<num;i++)
{
printf("\n%d",s1[i].rollno);
printf("\t%s",s1[i].name);
printf("\t%d",s1[i].m1);
printf("\t%d",s1[i].m2);
printf("\t%d",s1[i].m3);
s1[i].total=s1[i].m1+s1[i].m2+s1[i].m3;
printf("\t%d",s1[i].total);
}
getch();
}
OUTPUT:
PROGRAM FOR SIZE OF UNION
AIM:
To write a c program to store the book information using union.
ALGORITHM:
Result:
Thus the above programs was written and executed successfully.