tags:

views:

18

answers:

1

I have made a program in graphics but when ever i enter any value in the graph it reaches its peak

 #include <graphics.h>
#include <dos.h>
#include <graphics.h>
#include <conio.h>
#define LEFT 5
#define BOT 300
#define BWIDTH 10
#define TOPFLAG 1
#define BDEPTH 4
#define SEPARATION 12
#define SPACE 15
#define N 10
#define TOP 5
#define PPD (float(BOT)-TOP)*100
#define DI (BWIDTH+SEPARATION)
#define WIDTH (N+1)*DI
void main(void)
{
    int driver=DETECT;
    int mode;
    initgraph(&driver,&mode,"C:\\TC\\bgi");
    cleardevice();
    rectangle(LEFT,TOP,LEFT+WIDTH,BOT);
    int arr[N]={1,2,3,4,5,6,7,8,9,10};
    for(int i=0;i<N;i++)
    {
    setfillstyle(SOLID_FILL,1+i%3);
    bar3d(SPACE+LEFT+i*DI,BOT-(arr[i]*PPD),LEFT+SPACE+i*DI+BWIDTH,BOT,BDEPTH,TOPFLAG);



}



    getch();
    closegraph();





}
A: 

Hans is right, but I think you have a * where you want a / - the definition of PPD should be:

#define PPD (((BOT)-(TOP))/100.0)

Now, come join us in the 21st century!

caf