Monday, March 16, 2026

Write a program for finding the max and min from the three numbers || C Lab Program

WAP_A01: Write a program for finding the max and min from the three numbers || Simple Numeric Problems 


Algorithm


start
step1: Read a,b,c
step2: max, min  := a
step3: if b > max then
step4: max := b
step5: if b < min then
step6: min := b
step7: if c > max then
step8: max := c
step9: if c < max then
step10: min := c
step11: Print max,min
Stop



WAP_A01: C Lab Program


//finding the max and min from the three numbers

#include <stdio.h>
int main()
{
int a,b,c;
int max, min;
printf("Enter 3 integers: ");
scanf("%d%d%d",&a,&b,&c);
max = min = a;
if (b > max) {
        max = b;
    }
    if (b < min) {
        min = b;
    }

    if (c > max) {
        max = c;
    }
    if (c < min) {
        min = c;
    }

    // Output the results
    printf("%d is max\n", max);
    printf("%d is min\n", min);

return(0);
}


OUTPUT

Enter 3 integers: 60 20 30
60 is max
20 is min

For all 2026 published articles list: click here

...till the next post, bye-bye & take care.

No comments:

Post a Comment