Write a program for calculating the value of the function y = 1 / x.
August 7, 2021 | education
| Write a program for calculating the value of the function y = 1 / x. We know that you cannot divide by zero, so in the program, if x = 0, we will assign y the value 0.
Let us introduce the following notation: let x be a given number, the value of which will be entered from the keyboard during the execution of the program; y – the number, the value of which must be found depending on the entered number x. Then a program in the Pascal ABC programming language may look like this:
program zadacha;
uses crt;
var x: integer; y: real; {Description of x and y quantities}
begin
writeln (‘vvedite chislo x’);
readln (x); {Enter the value of the number x}
if x = 0 then y: = 0 else y: = 1 / x;
writeln (‘y =’, y); {Display the result y on the screen}
end.
One of the components of a person's success in our time is receiving modern high-quality education, mastering the knowledge, skills and abilities necessary for life in society. A person today needs to study almost all his life, mastering everything new and new, acquiring the necessary professional qualities.