๐Ÿ’ป
B.TECH I YEAR โ€ข I SEMESTER โ€ข R25

Programming for Problem Solving - Lab Manual

C Programming Laboratory โ€ข Program Solution

๐Ÿ“˜ R25 Regulation ๐ŸŽ“ I Year ๐Ÿ“š I Semester ๐Ÿ’ป C Programming ๐Ÿงช Lab Program
Selected Program

Write a program for finding the max and min from the three numbers.

โ† All Lab Programs

Write a program for finding the max and min from the three numbers.

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

Flowchart
flowchart for finding the max and min from the three numbers in c

C Programming
//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

๐Ÿ’ป Run This C Program

Write a program for finding the max and min from the three numbers.
The selected C program is loaded automatically. Edit the code, provide input through STDIN and click Run.

The compiler is embedded using OneCompiler. Your program runs in the embedded C environment; Study Glance does not execute C code directly on your web server.
โ† Back to PPS Lab Programs ๐Ÿ“š All Lab Manuals