Write a program that takes three integers, and prints out the smallest number
#include <stdio.h>
int findSmallest(int number1,int number2,int number3){
if (number1 < number2 && number1 < number3)
{
return number1;
}
if (number2 < number1 && number2 < number3)
{
return number2;
}
return number3;
}
int main()
{
int number1, number2, number3;
printf("Enter the first integer: ");
scanf("%d", &number1);
printf("Enter the second integer: ");
scanf("%d", &number2);
printf("Enter the third integer: ");
scanf("%d", &number3);
printf("The smallest number is %d\n\n",findSmallest(number1, number2, number3));
scanf("%d", &number2);
return 0;
}
Comments
Leave a comment