/c1.c
Created
April 9, 2023 12:40
1. C program to input any three numbers and find out which one is the largest number.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int findLargest(int num1, int num2, int num3); | |
void main() { | |
int num1, num2, num3, largest; | |
printf("Enter three numbers: "); | |
scanf("%d %d %d", &num1, &num2, &num3); | |
largest = findLargest(num1, num2, num3); | |
printf("The largest number is: %d\n", largest); | |
} | |
int findLargest(int num1, int num2, int num3) { | |
int largest = num1; | |
if (num2 > largest) { | |
largest = num2; | |
} | |
if (num3 > largest) { | |
largest = num3; | |
} | |
return largest; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment