A simple program to ask the user to give two numbers and then the program will display the original arrangement and swap arrangement of the two numbers using functions in the C++ programming language.
I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.
Program Listing
// swap.cpp
// Mr. Jake R. Pomperada, MAED-IT, MIT
// www.jakerpomperada.com
// jakerpomperada@gmail.com
// Bacolod City, Negros Occidental Philippines
#include <iostream>
#include <stdlib.h>
using namespace std;
void GetVal(int& Get1,int& Get2);
void SwapVal(int& Swap1,int& Swap2);
void ShowVal(int& Show1,int& Show2);
int main()
{
int FirstNum,SecondNum;
GetVal(FirstNum,SecondNum);
SwapVal(FirstNum,SecondNum);
ShowVal(FirstNum,SecondNum);
system("PAUSE");
return 0;
}
void GetVal(int& Get1,int& Get2)
{
cout << "\n\n";
cout << "\tSwap Two Numbers Using Functions in C++";
cout << "\n\n";
cout << "\tGive Two Values: ";
cin >> Get1 >> Get2;
cout << "\n\n";
cout << "\tOriginal Arrangement\n\n";
cout <<"\t" << Get1 << " " << Get2 << "\n";
cout << "\n\n";
cout << "\tSwap Arrangement\n\n";
cout << "\n\n";
}
void SwapVal(int& Swap1,int& Swap2)
{
int temp;
temp = Swap1;
Swap1 = Swap2;
Swap2 = temp;
}
void ShowVal(int& Show1,int& Show2)
{
cout <<"\t" << Show1 << " " << Show2 << "\n";
cout << "\n\n";
cout << "\tEnd of Program";
cout << "\n\n";
}
No comments:
Post a Comment