Course Content
Detailed Content of Programming in C
0/1
Introduction
0/1
Structure of C program
0/1
Answers of ‘C’ Pointers Programs
0/1
About Lesson

Create a program that takes three numbers as input and determines the largest among them.

#include <stdio.h>

int main() {
// Declare variables
float num1, num2, num3;

// Input: Get three numbers from the user
printf(“Enter three numbers: “);
scanf(“%f %f %f”, &num1, &num2, &num3);

// Process: Determine the largest among three numbers
if (num1 >= num2 && num1 >= num3) {
printf(“%.2f is the largest number.n”, num1);
} else if (num2 >= num1 && num2 >= num3) {
printf(“%.2f is the largest number.n”, num2);
} else {
printf(“%.2f is the largest number.n”, num3);
}

return 0; // Exit the program successfully
}