Develop a program that prompts the user to enter two (2) numbers. The program will display the numbers based on these conditions; if the first number is less than the second number the program will perform a swap operation on these two numbers and display them, otherwise the program will display the numbers as entered.

We don't do your homework for you. Write your code, and when you have problems with it, post it here for advice.

#include <iostream>
using namespace std;

int main() {

     int a;
     int b;
     int temp;

    cout << "Before swapping." << endl;

    cin>> a;
    cin>> b;

     if( a < b){

    temp = a;
    a = b;
    b = temp;

    cout << "\nAfter swapping." << endl;
    cout << "a = " << a << ", b = " << b << endl;

     }
    return 0;
}

Inline Code Example Here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.