Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reads in three numbers and writes them all in sorted order int main() { int n1, n2, n3;
//printf("Enter 3 numbers: "); scanf("%d %d %d", &n1, &n2, &n3);
// we'll store the numbers according to their order in these variables int lowest, middle, highest;
// n1 is the lowest number if (n1 <= n2 && n1 <= n3) { lowest = n1;
// figure out the remaining order between n2 and n3
if (n2 <= n3)
{
middle = n2;
highest = n3;
}
else
{
middle = n3;
highest = n2;
}
} // n2 is the lowest number else if (n2 <= n1 && n2 <= n3) { lowest = n2;
// figure out the remaining order between n1 and n3
if (n1 <= n3)
{
middle = n1;
highest = n3;
}
else
{
middle = n3;
highest = n1;
}
} // n3 is the lowest number else { lowest = n3;
// figure out the remaining order between n1 and n2
if (n1 <= n2)
{
middle = n1;
highest = n2;
}
else
{
middle = n2;
highest = n1;
}
}
printf("\n\n");
// output the numbers in ascending and descending order printf(" asc: %d %d %d\n\n", lowest, middle, highest); printf("desc: %d %d %d\n\n", highest, middle, lowest);
return 0; }