7. Write a C program that accepts three integers: a, b, and c, and prints them in ascending order

PHOTO EMBED

Fri Aug 18 2023 17:57:55 GMT+0000 (Coordinated Universal Time)

Saved by @Codes

// Online C compiler to run C program online
#include <stdio.h>

int main() {
    int a,b,c;
    int temp = 0;
    printf("Enter an integer for a: ");
    scanf("%d",&a);
    printf("Enter an integer for b: ");
    scanf("%d",&b);
    printf("Enter an integer for c: ");
    scanf("%d",&c);
    for(int i = 0;i <= 3; i++){
        if(a>b){
            temp = a;
            a = b;
            b = temp;
        }
        else if(b>c){
            temp = b;
            b = c;
            c = temp;
        }
    }
    printf("%d %d %d",a,b,c);

    return 0;
}
content_copyCOPY