C Programming

Solved Example

Practice Questions

Exercise Question

Find the youngest person

Objective

Enter the age of 3 persons Alex, Blake, Clark, and determine the youngest one.

Program/Solution:

#include<stdio.h>
int main() {
	int a,b,c;
	int min;
	
	printf("Enter age of Alex, Blake and Clark: ");
	scanf("%d%d%d",&a,&b,&c);
	
	if(a < b) {
		if(a < c) {
			printf("Alex is youngest");
		}else {
			printf("Clark is youngest");
		}
	}else {
		if(b < c) {
			printf("Black is youngest");
		}else {
			printf("Clark is youngest");
		}
	}
	
	return 0;
}

Sample Output:

Enter age of Alex, Blake and Clark: 22 15 32
Black is youngest

More Progarms of Decision Making in C

Calculate profit or loss

Check a number is even or odd

Check a number is positive or negative

Check a year is leap year or not

Find the first day of year

Absolute value of a number

Find area of rectangle is greater than perimeter

Check the points are co-linear or not

Check a point is inside,outside or on the circle

Check the axis of a point

Identify a character is alphabet, digit and more

Check the insurance eligibility and calculate premium

Calculate the library penalty charges

Calculate grade of a student