Write a MATLAB file to input any two numbers Divide the firs

Write a MATLAB file to input any two numbers. Divide the first number by the second number. If the second number is 0, give a warning and terminate the program. Output you result on screen with three-decimal accuracy.

Solution

x = input(\"Enter a number : \");
y = input(\"Enter another number : \");

if y == 0
fprintf(\"Error..!!Second Number entered is 0\ \");
else
z = x/y;
fprintf(\"Answer : %.3f\ \",z);
end

 Write a MATLAB file to input any two numbers. Divide the first number by the second number. If the second number is 0, give a warning and terminate the program

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site