C Exercises: Accepts three integers and find the maximum
C Basic Declarations and Expressions: Exercise-13 with Solution
Write a C program that accepts three integers and finds the maximum of three.
Pictorial Presentation:

C Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int x, y, z, result, max; // Declare variables
// Prompt user for the first integer and store in 'x'
printf("\nInput the first integer: ");
scanf("%d", &x);
// Prompt user for the second integer and store in 'y'
printf("\nInput the second integer: ");
scanf("%d", &y);
// Prompt user for the third integer and store in 'z'
printf("\nInput the third integer: ");
scanf("%d", &z);
// Calculate the result
result = (x + y + abs(x - y)) / 2;
// Calculate the maximum value
max = (result + z + abs(result - z)) / 2;
// Print the maximum value
printf("\nMaximum value of three integers: %d", max);
printf("\n");
return 0;
}
Sample Output:
Input the first integer: 25 Input the second integer: 35 Input the third integer: 15 Maximum value of three integers: 35
Flowchart:

C Programming Code Editor:
Previous: Write a C program that accepts an employee's ID, total worked hours of a month and the amount he received per hour. Print the employee's ID and salary (with two decimal places) of a particular month.
Next: Write a C program to calculate a bike’s average consumption from the given total distance (integer value) traveled (in km) and spent fuel (in liters, float number – 2 decimal point).
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join