repeating in pascal - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# repeating in pascal

Posts: 8Member
hi! i have exercise to create x and y value table from this function: y=4x^3-2x^2+5 and x goes from -3 to 1, but by step 0.1 (so the x is -3; -2,9; -2.8;....0,8; 0,9; 1); i got this far:

program numbers;
var x, y:integer;
begin
write('function y=4x^3-2x^2+5');
writeln('x values:');
for x:=-3 to 1 do
writeln(x); __________//at this plase i need that x goes -3; -2.9; -2.8 not -3; -2; -1

writeln('y values') _____//and this part i need to get in column, next to x column and also i cant get that program puts all x values from -3 to 1 in x place and shows all y values
y:=(4*x*x*x)-(2*x*x)+5;
writeln(y);
end.

and i also think that i cant use the integer; cause i will use 0,..; but when i replace integer with real there is error "invalid FOR control variable"
if you can something suggest, please repeat

• Posts: 8Member
if it helps to someone, who understands all this things then
i found something similar there:
http://ideone.com/0GoH8
but i need just 2 columms and x and y equation is different
• Posts: 35Member
[code]
program numbers;

function cube (x : real) : real ;
begin
cube := x * sqr(x)
end ;

var
x, y : real;
i : integer;

begin
write('function y = 4x^3 - 2x^2 + 5');
writeln('x values:');
for i := -30 to 10 do begin
x := i / 10.0 ;
y := 4.0 * cube(x) - 2.0 * sqr(x) + 5.0 ;
writeln (x:10:3, y:10:3)
end ;