jeudi 29 août 2019

problem creating a code to print maximum between 3 numbers

i wrote a program which takes 3 numbers from the user and prints out the maximum number, but when i run the program it is not taking the numbers from the user correctly

#include <stdio.h>
#include <stdlib.h>

int main()
{
int num1, num2, num3;
printf ("PROGRAM TO FIND THE BIGGEST NUMBER\n");
printf ("\n");

printf ("enter first number : ");
scanf ("%d ",&num1);

printf ("enter second number : ");
scanf ("%d ",&num2);

printf ("enter third number : ");
scanf ("%d ",&num3);

printf("%d - %d - %d \n",num1,num2,num3);


if (num1>num2 && num1>num3){
    printf ("the biggest number is %d",num1);

}
else if  (num2>num1 && num2>num3){
    printf ("the biggest number is %d",num2);
}
else if (num3>num1 && num3>num2){
    printf ("the biggest number is %d",num3);
}


return 0;
}

Aucun commentaire:

Enregistrer un commentaire