Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //take and order 3 integers
- #include <stdio.h>
- int main(void) {
- int num1, num2, num3;
- printf("Enter integer: \n");
- scanf("%d", &num1);
- printf("Enter integer: \n");
- scanf("%d", &num2);
- printf("Enter integer: \n");
- scanf("%d", &num3);
- printf("The numbers in order are: \n");
- // 123, 132
- if ((num1 <= num2) && (num1 <= num3)) {
- printf("%d ", num1);
- if (num2 <= num3) {
- printf("%d ", num2);
- printf("%d ", num3);
- } else {
- printf("%d ", num3);
- printf("%d ", num2);
- }
- }
- // 213, 312
- else if ((num2 <= num1) && (num3 <= num3)) {
- printf("%d ", num2);
- if (num1 <= num3) {
- printf("%d ", num1);
- printf("%d ", num3);
- } else {
- printf("%d ", num3);
- printf("%d ", num1);
- }
- // 312, 321
- } else {
- printf("%d ", num3);
- if (num1 <= num2) {
- printf("%d ", num1);
- printf("%d ", num2);
- } else {
- printf("%d ", num2);
- printf("%d ", num1);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement