Thread: Error in Line - 4 " ) Expected"

  1. #1
    Registered User
    Join Date
    Jan 2017
    Posts
    1

    Error in Line - 4 " ) Expected"

    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();
    }

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > 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.
    1. You're using a compiler that's been obsolete for over 25 years.
    2. You're trying to compile C++ syntax with a C compiler. C doesn't have references.


    > x*10;
    > x-ret;
    > x/10;
    These statements do nothing.
    Perhaps you mean things like
    x *= 10;

    Oh and the whole void main thing.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. expected ";" before "const" error.
    By Aenn in forum C++ Programming
    Replies: 0
    Last Post: 01-18-2015, 11:08 AM
  2. Replies: 10
    Last Post: 08-09-2012, 12:48 PM
  3. Replies: 3
    Last Post: 04-26-2009, 05:59 AM
  4. Replies: 9
    Last Post: 03-31-2009, 04:23 PM

Tags for this Thread