Facebook
From Anuj, 1 Month ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 139
  1.  
  2. Facebook
  3. exam safest cryptocurrency exchange
  4. From cga, 8 Hours ago, written in Plain Text.
  5. URL https://pastebin.pl/view/c100958d
  6. Embed Show code
  7. Download Paste or View Raw
  8. Hits: 37
  9.      
  10.  
  11. 1)draw coordinate axis at centre of screen
  12. #include<graphics.h>
  13. #include<conio.h>
  14. void main()
  15. {
  16. int gd=DETECT,gm,xcen,ycen;
  17. initgraph(&gd;,&gm;,"C:\\TC\\BGI");
  18. xcen=getmaxx()/2;
  19. ycen=getmaxy()/2;
  20. line(xcen,0,xcen,getmaxy());
  21. line(0,ycen,getmaxx(),ycen);
  22. getch();
  23. closegraph();
  24. }
  25.  
  26. 2)
  27. a. Develop the program for DDA Line drawing algorithm.
  28. CODE:
  29. #include<stdio.h>
  30. #include<conio.h>
  31. #include<graphics.h>
  32. #include<math.h>
  33. #include<dos.h>
  34. void main()
  35. {
  36. int gd=DETECT,gm;
  37. float x1,y1,x2,y2,i,dx,dy,m;
  38. printf("\nEnter the x1 and y1 coordinate: ");
  39. scanf("%f%f",&x1;,&y1;);
  40. printf("\nEnter the x2 and y2 coordinate: ");
  41. scanf("%f%f",&x2;,&y2;);
  42. m=(y2-y1)/(x2-x1);
  43. initgraph(&gd;,&gm;,"C:\\TC\\BGI");
  44. for(i=x1;i<=x2;i++)
  45. {
  46. if(m<1)
  47. {
  48. dx=x1+1;
  49. dy=y1+m;
  50. }
  51. else if(m>1)
  52. {
  53.  
  54. }
  55. else
  56. {
  57.  
  58. }
  59. dx=x1+(1/m);
  60. dy=y1+1;
  61.  
  62. dx=x1+1;
  63. dy=y1+1;
  64.  
  65. abs(dx);
  66. abs(dy);
  67. putpixel(dx,dy,15);
  68. x1=dx;
  69. y1=dy;
  70. delay(50);
  71. }
  72. outtextxy(x2,y2,"DDA LINE");
  73. getch();
  74. closegraph();}
  75.  
  76. 3)
  77. 5A WRITE A PROGRAM TO IMPLEMENT 2D SCALING
  78. A1 WRITE A PROGRAM TO SCALE 2D LINE
  79. CODE:
  80. #include<conio.h>
  81. #include<stdio.h>
  82. #include<graphics.h>
  83. void main()
  84. {
  85. float x1,x2,y1,y2,sx,sy;
  86. int gd=DETECT,gm;
  87. printf("\nEnter Start Cooridinate (x1,y1): ");
  88. scanf("%f%f",&x1;,&y1;);
  89. printf("\nEnter the End Cooridinate(x2,y2): ");
  90. scanf("%f%f",&x2;,&y2;);
  91.  
  92. printf("'\nEnter Scaling Parmeters: ");
  93. scanf("%f%f",&sx;,&sy;);
  94. initgraph(&gd;,&gm;,"C:\\TC\\BGI");
  95. line(x1,y2,x2,y2);
  96. outtextxy(x1,y1,"Line Before Scaling");
  97. x1=x1*sx;
  98. y1=y1*sy;
  99. x2=x2*sx;
  100. y2=y2*sy;
  101. line(x1,y1,x2,y2);
  102. outtextxy(x1,y1,"Line After Scaling");
  103. getch();
  104. closegraph();
  105. }
  106.  
  107. 4)
  108. A)Develop a simple text screen saver using graphics functions.
  109. #include <stdio.h>
  110. #include <stdlib.h>
  111. #include <graphics.h>
  112. #include <conio.h>
  113. #include <dos.h>
  114. void main()
  115. {
  116. int
  117. gdriver=DETECT,gmode,col=480,row=640,font=4,direction=2,size=8,col
  118. or=15;
  119. initgraph(&gdriver;,&gmode;,"C:\\TurboC3\\BGI");
  120. cleardevice();
  121. while(!kbhit()){
  122. settextstyle(random(font),random(direction),random(size));
  123. setcolor(random(color));
  124. outtextxy(random(col),random(row),"Komal");
  125. delay(250);
  126. }
  127. closegraph();
  128. }
  129.  
  130. 5)
  131. B. Draw a simple hut on the screen.
  132.  
  133. CODE:
  134. #include<graphics.h>
  135. #include<conio.h>
  136. void main()
  137. {
  138. int gd=DETECT, gm;
  139. initgraph(&gd;,&gm;,"C:\\TC\\BGI");
  140. rectangle(150,180,250,300);
  141. rectangle(250,180,420,300);
  142. rectangle(180,250,220,300);
  143. line(200,100,150,180);
  144. line(200,100,250,180);
  145. line(200,100,370,100);
  146. line(370,100,420,180);
  147. getch();
  148. closegraph();
  149. }
  150.  
  151. 6)
  152. A. Divide your screen into four region, draw circle, rectangle, ellipse and
  153. half ellipse in each region
  154.  
  155. CODE:
  156. #include<graphics.h>
  157. #include<conio.h>
  158. void main()
  159. {
  160. int gd=DETECT,gm,xcen,ycen;
  161. initgraph(&gd;,&gm;,"C:\\TC\\BGI");
  162. xcen=getmaxx()/2;
  163. ycen=getmaxy()/2;
  164. line(xcen,0,xcen,getmaxy());
  165. line(0,ycen,getmaxx(),ycen);
  166. rectangle(xcen+50,ycen-200,xcen+200,ycen-50);
  167. ellipse(xcen-xcen/2,ycen+ycen/2,0,360,100,50);
  168. ellipse(xcen+xcen/2,ycen+ycen/2,0,180,100,50);
  169. getch();
  170. closegraph();
  171. }
  172. 7)
  173. B) Perform smiling face animation using graphic functions.
  174. #include<stdio.h>
  175. #include<conio.h>
  176. #include<graphics.h>
  177. #include<stdlib.h>
  178. void main()
  179. {
  180. int gd=DETECT,gm,x=250,y=250;
  181. initgraph(&gd;,&gm;,"C:\\TC\\BGI");
  182. cleardevice();
  183. while(!kbhit())
  184. {
  185. setfillstyle(SOLID_FILL,14);
  186. fillellipse(x,y,100,100);
  187. setfillstyle(SOLID_FILL,random(6));
  188. fillellipse(x-30,y-30,20,40);
  189. fillellipse(x+30,y-30,20,40);
  190. setcolor(random(3));
  191. ellipse(x,y+10,180,0,60,50);
  192. delay(500);
  193. }
  194. closegraph();
  195. }
  196.  
  197. 8)
  198. 5B: WRITE A PROGRAM TO IMPLEMENT 2D Translation
  199. B1 WRITE A PROGRAM TO IMPLEMENT 2D Translation on a line
  200. CODE:
  201. #include<stdio.h>
  202. #include<conio.h>
  203. #include<graphics.h>
  204. void main()
  205. {
  206. int gd=DETECT,gm;
  207. float Tx,Ty,x1,y1,x2,y2;
  208. printf("Enterthe coordinates(x1,y1):");
  209.  
  210. SYIT CGA Practical
  211.  
  212. Komal Jambhale 6
  213. scanf("%f%f",&x1;,&y1;);
  214. printf("Enterthe second coordinations(x1,y2)");
  215. scanf("%f%f",&x2;,&y2;);
  216. printf("Enterthe translation parameter(Tx,Ty)");
  217. scanf("%f%f",&Tx;,&Ty;);
  218. initgraph(&gd;,&gm;,"C:\\TC\\BGI");
  219. line(x1,y1,x2,y2);
  220. outtextxy(x1,y1,"Before Translation");
  221. x1=x1+Tx;
  222. y1=y1+Ty;
  223. x2=y2+Tx;
  224. y2=y2+Ty;
  225. line(x1,y1,x2,y2);
  226. outtextxy(x2,y2,"After Translation");
  227. getch();
  228. closegraph();
  229. }
  230.