Categories
C++

Swap Two Numbers Using Functions in C++

 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.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

// 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";
}
Categories
C++

Smallest and Biggest Element in an Array in C++

 I wrote this program to ask the user to give a series of elements in an array and then it will check what element has the smallest and biggest numerical values using C++ programming languages.

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.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Program Listing

// arrays.cpp

// Jake R. Pomperada, MAED-IT,MIT

// www.jakerpomperada.com

// www.jakerpomperada.blogspot.com

// jakerpomperada@gmail.com

// Bacolod City, Negros Occidental





#include<iostream>



int main ()

{

    int arr[20];

	int n=0, i=0, max=0, min=0;

    std::cout <<"\n\n";

    std::cout <<"\tSmallest and Biggest Element in an Array in C++";

    std::cout <<"\n\n";

    std::cout << "\tGive the size of the array : ";

    std::cin >> n;

    std::cout <<"\n\n";

     for (i = 0; i < n; i++) {

	   std::cout << "\tGive value in element no. " << i+1 << " : ";

       std::cin >> arr[i];

       }

    max = arr[0];

    for (i = 0; i < n; i++)

    {

        if (max < arr[i])

            max = arr[i];

    }

    min = arr[0];

    for (i = 0; i < n; i++)

    {

        if (min > arr[i])

            min = arr[i];

    }

    std::cout <<"\n\n";

    std::cout << "\tThe Biggest  Element : " << max;

    std::cout <<"\n\n";

    std::cout << "\tThe Smallest Element : " << min;

    std::cout <<"\n\n";

    std::cout <<"\tEnd of Program";

  }