Home excel It is impossible to output the result. "Get the table function y...

It is impossible to output the result. “Get the table function y (x) = 0.5x ^ 2 – 7x with a change x from -4 to 4 in increments 0.5

Author

Date

Category

recently began to study VBA Excel and ran into a problem. Actually, the task in the title. Here is my solution, but displays the result incorrectly (only for x = 4). Oh yeah, I know that there are many chips in all programming languages, but it is necessary to decide that it is necessary to decide only from what I studied according to the program.
Here is the “decision”

sub n6 ()
Dim X AS Single, Y As Single, I AS Single
For x = (-4) to 4 STEP 0.5
 For i = 1 to 10 Step 1
  Cells (I, 1) = x
  Cells (I, 2) = Y
 NEXT I.
 y = (0.5 * (x) ^ 2) - 7 * x
NEXT X.
End Sub.

Hope someone will answer D: (P.S. Yes, I’m a beginner kettle, do not beat)


Answer 1

sub n6 ()
Dim X As Single, I AS Integer
For x = (-4) to 4 STEP 0.5
  i = i + 1
  Cells (I, 1) = x
  Cells (I, 2) = 0.5 * x ^ 2 - 7 * x
NEXT X.
End Sub.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions