Monday, 14 April 2014

Write a Cpp To Implement The Template Design


Write a C++ Program To Implement The Template Design

Ex: No: 8 TEMPLATE DESIGN IN C ++

Aim:To write a c ++ program to implement the template design

Algorithm:

Step 1: Start the program.
Step 2: Declare the main function and get the swap variables a, b, and c, d.
Step 3: We can invoke the swap () function like carry ordinary function.
Step 4: Then display the swap variables.
Step 5: Stop the program.

Program:

#include
#include
void swap(int,int);
void swap(float,float);
void main()
{
clrscr();
int a,b;
float c,d;
cout<<”ENTER THE VALUES FOR A&B:”<
cin>>a>>b;
cout<<”ENTER THE VALUES FOR C&D:”<
cin>>c>>d;
swap(a,b);
swap(c,d);
}
template
void swap(t x,t y)
{
t temp;
temp=x;
x=y;
y=temp;
cout<
getch();
}

Output:

Enter the values for A&B:
13
65
Enter the values for C &D:

23
78
65137823

Result:
Thus the implementation of c ++ program for template design is executed and the output has been verified.

0 comments:

Post a Comment