I use the Turbo C++ 3.0 to run this C program with the file name DDA.C. In line 4 it gives the error " ) Expected". Please tell me whats wrong with my code. I am trying to implement DDA Algorithm. ro function is being used to roundoff a number.
Code:
#include<conio.h>
#include<graphics.h>
#include<stdio.h>
void ro(float &x)
{
float ret=x,t=x;
ret=ret*10;
t=t*10;
ret=ret-t;
if(ret<5.0)
{
x*10;
x-ret;
x/10;
}
else if(ret>=5.0)
{
x*10;
x-ret;
x=x+1;
x/10;
}
};
void main()
{
int gd=DETECT,gm,x1,i,x2,y1,y2,dy,dx;
float m,temp;
clrscr();
printf("\n\tEnter Two Co-ordinates");
printf("\n\n\tX1: ");
scanf("%d",&x1);
printf("\n\tY1: ");
scanf("%d",&y1);
printf("\n\tX2: ");
scanf("%d",&x2);
printf("\n\tY2: ");
scanf("%d",&y2);
initgraph(&gd,&gm,"C:\\TC\\BGI");
clrscr();
dy=y2-y1;
dx=x2-x1;
m=dy/dx;
if(dy>dx)
{
for(i=y1;i<=y2;i++)
{
temp=x1;
putpixel(ro(&temp),i,WHITE);
temp=temp+m;
}
}
getch();
}