Friday , December 15 2017

Recent Posts

C Program for Drawing a Line using Bresenham Line Algorithm

#include<graphics.h> #include<conio.h> #include<stdio.h> void main() { int gd=DETECT,gm; int x1,y1,x2,y2,x,y,dy,dx,p; float m; clrscr(); initgraph(&gd,&gm,"c:\\tc\\"); printf("Enter first co-ords of line\n"); scanf("%d",&x1); scanf("%d",&y1); printf("Enter second co-ords of line\n"); scanf("%d",&x2); scanf("%d",&y2); dy=y2-y1; dx=x2-x1; m=(float)(y2-y1)/(x2-x1); x=x1;y=y1; if(m>1.0) { printf("This algorithm is not applicable!!! press Enter to exit\n"); }else { p=2*dy-dx; while(x<x2) { if(p>=0) { putpixel(x,y,5); y=y+1; p=p+2*dy-2*dx; } else { putpixel(x,y,5); p=p+2*dy; } x=x+1; ...

Read More »

C Program for Drawing a Circle using Bresenham Circle Algorithm

#include<graphics.h> #include<conio.h> #include<stdio.h> void main() { int gd=DETECT,gm; int d,r,x,y,xc,yc; clrscr(); initgraph(&gd,&gm,"c:\\tc\\"); printf("Enter Radius\n"); scanf("%d",&r); printf("Enter Center of circle\n"); scanf("%d",&xc); scanf("%d",&yc); d=3-2*r; x=0; y=r; while(x<=y) { putpixel(xc+x,yc+y,5); putpixel(xc-y,yc-x,5); putpixel(xc+y,yc-x,5); putpixel(xc-y,yc+x,5); putpixel(xc+y,yc+x,5); putpixel(xc-x,yc-y,5); putpixel(xc+x,yc-y,5); putpixel(xc-x,yc+y,5); if(d<=0) { d=d+4*x+6; } else { d=d+4*x-4*y+10; y=y-1; } x=x+1; } getch(); } Output: Tags: C program for drawing a circle using Bresenhams circle algorithm, C ...

Read More »

Program for string in cross x format on given position

Program for string in x format on given contact position in the middle of your output screen  class formatx { public static void main(String s,int n) { int i,j,k,l=s.length(); char a[][]=new char[l*l][l*l]; j=l/2; for(i=0;i<15-j;i++) System.out.println(); for(i=0;i<l;i++)< span=""> a[i][l+i]=s.charAt(i); j=l+n; k=n-2; for(i=n-2;i>-1;i--) a[i][j++]=s.charAt(k--); j=l+n-2; k=n; for(i=n;i<l;i++)< span=""> a[i][j--]=s.charAt(k++); for(i=0;i<l;i++)< span=""> { for(j=0;j<65-l-n;j++) System.out.print(' '); for(j=0;j<l*3;j++)< span=""> { if(a[i][j]!=0) System.out.print(a[i][j]); else System.out.print(' ...

Read More »