Write a program to fill a circle using boundary fill algorithm


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

void boundryFill(int, int, int, int);
int midx=319, midy=239;

void main()
{
  int gdriver=DETECT, gmode, x,y,r;
  initgraph(&gdriver, &gmode, "c:\\tc\\bgi");

  cleardevice();

  printf("Enter the Center of circle (X,Y) : ");
  scanf("%d %d",&x,&y);
  printf("Enter the Radius of circle R : ");
  scanf("%d",&r);

  circle(midx+x,midy-y,r);
  getch();
  boundryFill(midx+x,midy-y,13,15);

  getch();
  closegraph();
}

void boundryFill(int x, int y, int fill, int boundry)
{
  if( (getpixel(x,y) != fill) && (getpixel(x,y) != boundry) )
  {
      putpixel(x,y,fill);
      delay(5);
      boundryFill(x+1,y,fill,boundry);
      boundryFill(x-1,y,fill,boundry);
      boundryFill(x,y+1,fill,boundry);
      boundryFill(x,y-1,fill,boundry);
  }
}

Read more...

Write a program to fill a circle using flood fill algorithm


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

void floodFill(int, int, int, int);
int midx=319, midy=239;

void main()
{
      int gdriver=DETECT, gmode, x,y,r;
      initgraph(&gdriver, &gmode, "c:\\tc\\bgi");

      cleardevice();

      printf("Enter the Center of circle (X,Y) : ");
      scanf("%d %d",&x,&y);
      printf("Enter the Radius of circle R : ");
      scanf("%d",&r);

      circle(midx+x,midy-y,r);
      getch();
      floodFill(midx+x,midy-y,13,0);

      getch();
      closegraph();
}

void floodFill(int x, int y, int fill, int old)
{
      if(getpixel(x,y) == old)
      {
            putpixel(x,y,fill);
            delay(5);
            floodFill(x+1,y,fill,old);
            floodFill(x-1,y,fill,old);
            floodFill(x,y+1,fill,old);
            floodFill(x,y-1,fill,old);
      }
}

Read more...

system programming rku lab work

  • Tutorial : 1
  • Tutorial : 2
  • Tutorial : 3
1.macro definition program make different table
  • Tutorial : 4
1. Top Down Parsing
  • Tutorial : 5
1. Bottom-Up Parsing

Read more...

Macro definition program make a table

//copy below program  and save file_name.c 

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>

struct MNT
{
    char mname[20];
    int  mdtp;
}mnt[5];

struct MDT
{
    char opcode[15],rest[35];
}mdt[30];

char arglist[15][15],apt[10][15];
int  mdtp=0,mntp=0,arglistp=0;
char FName[20], TName[20];
char Buffer[80], temp[40],tok1[40];
int pp,kpp;// no. of positional and keyword parameters
FILE *fp1, *fp2;

int SearchMNT(char *s)
{     int i;
    for(i=0; i<mntp; i++)
        if(strcmpi(s,mnt[i].mname)==0)
            return(i);
    return(-1);
}
int SearchPNT(char *s)
{     int i;
    for(i=0;i<arglistp;i++)
        if(strcmpi(arglist[i],s)==0)
            return(i);
    return(-1);
}

void Print_MNT()
{     int i;
    printf("\n\n----------MACRO NAME TABLE---------------------");
    printf("\n#\tMName\t#MDTP");
    printf("\n-----------------------------------------------");
    for(i=0;i<mntp;i++)
        printf("\n%d\t%s\t%d",
        i,mnt[i].mname,mnt[i].mdtp);
    printf("\n------------------------------------------------");
    getch();
}

void Print_PNT()
{     int i;
    printf("\n\n------PARAMETER NAME TABLE--------");
    printf("\n#\tPName");
    printf("\n----------------------------------");
    for(i=0;i<arglistp;i++)
        printf("\n%d\t%s\t%s",i,arglist[i],apt[i]);
    printf("\n----------------------------------");
    getch();
}

Read more...
Related Posts Plugin for WordPress, Blogger...

Engineering material

GTU IDP/ UDP PROJECT

GTU IDP/ UDP PROJECT

Patel free software download

  © Blogger templates The Professional Template by Ourblogtemplates.com 2008

Back to TOP