diff --git a/Answers/ans1_output.png b/Answers/ans1_output.png new file mode 100644 index 0000000..1d31105 Binary files /dev/null and b/Answers/ans1_output.png differ diff --git a/Answers/ans3_output.png b/Answers/ans3_output.png new file mode 100644 index 0000000..8f01d93 Binary files /dev/null and b/Answers/ans3_output.png differ diff --git a/Answers/mohit_1901011(code1) b/Answers/mohit_1901011(code1) new file mode 100644 index 0000000..6fd16a3 --- /dev/null +++ b/Answers/mohit_1901011(code1) @@ -0,0 +1,38 @@ +#include +#include +int main( ) +{ +int gd=DETECT, gm, x0, y0, x1, y1, dx, dy, p, x, y; +printf("Co-ordinates of first point: "); +printf("\nEnter the value of x1: "); +scanf("%d",&x0); +printf("Enter the value of y1: "); +scanf("%d",&y0); +printf("Co-ordinates of second point: "); +printf("\nEnter the value of x2: "); +scanf("%d",&x1); +printf("Enter the value of y2: "); +scanf("%d",&y1); +initgraph(&gd,&gm,""); +dx=x1-x0; +dy=y1-y0; +x=x0; +y=y0; +p=2*dy-dx; +while(x=0) +{ +putpixel(x,y,4); +y=y+1; +p=p+2*dy-2*dx; +} +else +{ +putpixel(x,y,4); +p=p+2*dy; +} +x=x+1; +} +getch(); +return 0; diff --git a/Answers/mohit_1901011(code2) b/Answers/mohit_1901011(code2) new file mode 100644 index 0000000..347505b --- /dev/null +++ b/Answers/mohit_1901011(code2) @@ -0,0 +1,29 @@ +#include +#include +int main( ){ +int gd=DETECT,gm; +int t[3][3]={1,0,0,0,1,0,0,0,1},a[3][3],r[3][3]={0},i,j,k; +printf("Enter value of x1 and y1: "); scanf("%d %d", &a[0][0], &a[0][1]); +printf("Enter value of x2 and y2: "); scanf("%d %d", &a[1][0], &a[1][1]); +printf("Enter value of x3 and y3: "); scanf("%d %d", &a[2][0], &a[2][1]); +printf("Enter value of tx and ty: "); scanf("%d %d", &t[2][0], &t[2][1]); +a[0][2]=a[1][2]=a[2][2]=1; +for(i=0;i<3;i++){ +for(j=0;j<3;j++){ +for(k=0;k<3;k++){ +r[i][j] = r[i][j] + (a[i][k]*t[k][j]); +} +} +} +initgraph(&gd,&gm,"NULL"); +line(a[0][0],a[0][1],a[1][0],a[1][1]); +line(a[1][0],a[1][1],a[2][0],a[2][1]); +line(a[0][0],a[0][1],a[2][0],a[2][1]); +outtext("- - - Before Translation - - -"); +delay(5000); +cleardevice(); +line(r[0][0],r[0][1],r[1][0],r[1][1]); +line(r[1][0],r[1][1],r[2][0],r[2][1]); +line(r[0][0],r[0][1],r[2][0],r[2][1]); +outtext("- - - After Translation - - -"); +delay(5000);closegraph( );return 0 ;}