6 Replies - 1145 Views - Last Post: 29 December 2010 - 05:48 PM Rate Topic: -----

#1 zeynep  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 7
  • Joined: 24-December 10

Ancient Turbo C++ Code "Doesn't Run"

Posted 28 December 2010 - 02:39 PM

# include "graphics.h"

  

main( )

{ 

int i, j, x1, y1, r, p, a ;

int gd = DETECT, gm, x, y ;

  

printf ( "Enter coordinates of center and radius of circle" ) ;

scanf ( "%d %d %d", &x, &y, &r ) ;

initgraph ( &gd, &gm, "c:\\tc\\bgi" ) ;

  

x1 = 0.0 ;

y1 = r ;

  

p = 3 - 2 * r ;

  

while ( x1 < y1 )

{ 

plotcircle ( x, y, x1, y1 ) ; 

 

if ( p < 0 )

p = p + 4 * x1 + 6 ; 

else

{

p = p + 4 * ( x1 - y1 ) + 10 ;

y1 = y1 - 1 ;

}

x1 = x1 + 1 ; 

} 

if ( x1 == y1 )

plotcircle ( x, y, x1, y1 ) ;

  

getch( ) ;

closegraph( ) ;

restorecrtmode( ) ;

}

  

plotcircle ( int x, int y, int x1, int y1 )

{

putpixel ( x + x1, y + y1, 15 ) ;

putpixel ( x - x1, y + y1, 15 ) ;

putpixel ( x + x1, y - y1, 15 ) ;

putpixel ( x - x1, y - y1, 15 ) ;

putpixel ( x + y1, y + x1, 15 ) ;

putpixel ( x - y1, y + x1, 15 ) ;

putpixel ( x + y1, y - x1, 15 ) ;

putpixel ( x - y1, y - x1, 15 ) ;

}


THİS İS CODE WHY DONT İT RUN?

Mod Edit:
When posting code please use code tags like below.
:code:

Also, do NOT name your topic "HELP ME". We KNOW you need help...it's WHY you came HERE and POSTED!!!

This post has been edited by JackOfAllTrades: 28 December 2010 - 03:05 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Ancient Turbo C++ Code "Doesn't Run"

#2 brds  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 76
  • View blog
  • Posts: 515
  • Joined: 22-October 08

Re: Ancient Turbo C++ Code "Doesn't Run"

Posted 28 December 2010 - 03:20 PM

Do you have Turbo C installed? You will need it for this code.

What version of windows are you running? Turbo C may have special needs depending on version.

Why are you using a compiler suite that is potentially older than you are?

Also its int main(void) not main(), also add a return to the end of the main program. Main always returns an int.

The function plotcircle is not prototyped.

Just because Turbo C will let you do sloppy things, doesn't mean that you shouldn't #include <stdio.h>. as it is required for scanf and printf.

#include <stdio.h>
#include <graphics.h>

void plotcircle(int x, int y, int x1, int y1);

int main(void)
{
    /* Code */

    return 0; /* Success! */
}

void plotcircle(int x, int y, int x1, int y1)
{
    /* Code */
}



Other wise I cannot see what or if anything is wrong.
Was This Post Helpful? 2
  • +
  • -

#3 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Ancient Turbo C++ Code "Doesn't Run"

Posted 28 December 2010 - 03:21 PM

Most likely because ultimately it is calling obsolete routines that modern hardware doesn't use any longer. Secondly, it most likely won't compile into a modern instruction set for today's graphics hardware. :)
Was This Post Helpful? 2
  • +
  • -

#4 DivideByZero  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 238
  • View blog
  • Posts: 551
  • Joined: 02-December 10

Re: Ancient Turbo C++ Code "Doesn't Run"

Posted 28 December 2010 - 03:58 PM

Download visual studio and never touch turbo c/c++ ever again.
Was This Post Helpful? 2
  • +
  • -

#5 zeynep  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 7
  • Joined: 24-December 10

Re: Ancient Turbo C++ Code "Doesn't Run"

Posted 29 December 2010 - 12:21 PM

ok but ı found the problem :sigh: thanks...
Was This Post Helpful? -1
  • +
  • -

#6 newclearner  Icon User is offline

  • D.I.C Regular

Reputation: 103
  • View blog
  • Posts: 302
  • Joined: 29-September 10

Re: Ancient Turbo C++ Code "Doesn't Run"

Posted 29 December 2010 - 12:34 PM

but you will land up in another problem if you keep using turbo c++
Was This Post Helpful? 0
  • +
  • -

#7 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Ancient Turbo C++ Code "Doesn't Run"

Posted 29 December 2010 - 05:48 PM

View Postzeynep, on 29 December 2010 - 06:21 PM, said:

ok but ı found the problem :sigh: thanks...

Are you using old hardware with an old OS? :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1