0% found this document useful (0 votes)
13 views5 pages

Code

Uploaded by

abdo468655
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views5 pages

Code

Uploaded by

abdo468655
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

#include <iostream>

int main() {
int num1, num2, num3;

std::cout << "Enter three


numbers: ";
std::cin >> num1 >> num2 >>
num3;

// Sorting the numbers in


ascending order
if (num1 > num2) {
int temp = num1;
num1 = num2;
num2 = temp;
}

if (num1 > num3) {


int temp = num1;
num1 = num3;
num3 = temp;
}
if (num2 > num3) {
int temp = num2;
num2 = num3;
num3 = temp;
}

std::cout << "Numbers in


ascending order: " << num1 << "
" << num2 << " " << num3 <<
std::endl;

// Sorting the numbers in


descending order
if (num1 < num2) {
int temp = num1;
num1 = num2;
num2 = temp;
}
if (num1 < num3) {
int temp = num1;
num1 = num3;
num3 = temp;
}

if (num2 < num3) {


int temp = num2;
num2 = num3;
num3 = temp;
}

std::cout << "Numbers in


descending order: " << num1 <<
" " << num2 << " " << num3 <<
std::endl;

return 0;
}

You might also like