whats wrong with this program
#include <math.h>
#include <iostream.h>
#include <stdlib.h>
int rounding( int y,int yaxis)
{
double a;
char *buffer;
int decimal,sign;
a = (y+10)/yaxis;
buffer = _fcvt( a, 0 , &decimal , &sign );
return buffer;
};
void main()
{
const screen_length = 79;
const screen_height = 24;
const minx = -10;
const maxx = 10;
const miny = -10;
const maxy = 100;
int column,row,x,y,yaxis,xaxis;
double a,b;
//float ;
int temp;
char h;
a = abs(minx * (screen_length - 1) / (maxx - minx));//find the absolute value of a
b = abs(maxy * (screen_height - 1) / (maxy - miny));//find the absolute value of b
xaxis = (maxx - minx) / (screen_length - 1);
yaxis = (maxy - miny) / (screen_height - 1);
for (row=1;row<screen_height;row++)
{
x = minx;
for(column=0; column < screen_length ;column++)
{
y = x * x;
if(row == screen_height-rounding(y,yaxis))
cout<<'*';
else
if(column == a)
cout<<'|';
else
if(b == row-1)
cout<<'_';
else
cout<<' ';
x = x + xaxis;
}
cout<<endl;
}
}
here is the equivalent working program in pascal
the pascal program works
damn im having serious probelms in converting it
pls help
PROGRAM GRAPHIC(INPUT,OUTPUT);
VAR
ROW,COL,A,B : INTEGER ;
X,Y,YSCALE,XSCALE : REAL ;
CONST
SCREEN_LENGTH = 77 ;
SCREEN_HEIGHT = 24 ;
MINX = -10 ;
MAXX = 10 ;
MINY = -10 ;
MAXY = 100 ;
BEGIN
A:=ROUND(ABS(MINX*(SCREEN_length-1)/(MAXX-MINX)));
B:=ROUND(ABS(MAXY*(SCREEN_HEIGHT-1)/(MAXY-MINY)));
XSCALE := (MAXX-MINX)/(SCREEN_LENGTH-1);
YSCALE := (MAXY-MINY)/(SCREEN_HEIGHT-1);
FOR row:=1 TO SCREEN_HEIGHT DO
BEGIN
X:=minx;
FOR col := 0 TO SCREEN_LENGTH DO
BEGIN
Y:= X*X;
IF (ROW = SCREEN_HEIGHT-ROUND((Y+10)/YSCALE)) THEN
begin
WRITE('*')
end
ELSE IF (COL = A)THEN
begin
WRITE(':');
end
ELSE IF (ROW-1=B) THEN
begin
WRITE ('_')
end
ELSE
begin
WRITE(' ');
end;
X:=X+XSCALE;
END;
WRITELN;
END;
READLN
END.