Automata Question -7
Q7. Find the greatest of three numbers.
int main()
{
int num1, num2, num3;
scanf(“%d %d %d”, &num1,&num2,&num3);
if (num1 > num2) && (num1 > num3)
{
printf(“%d”, num1);
}
elseif(num2>num3)
{
printf(“%d”, num2)
}
else
{
printf(“%d”, num3);
}
return 0;
}
Answer: Error: Syntax error
if (num1 > num2) && (num1 > num3) à it has to be written as if ((num1 > num2) &&
(num1 > num3)) and this line elseif(num2>num3) should be rewritten as else
if(num2>num3)
Login/Signup to comment