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);
readln;
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
Comments
i found something similar there:
http://ideone.com/0GoH8
but i need just 2 columms and x and y equation is different
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 ;
readln;
end.
[/code]
i had a such problem
[link=http://www.programmersheaven.com]02.05.1994llls[/link]