Program to draw 2 rectangles and fill 1 of them in cpp

  #include <iostream.h> #include <conio.h> #include <graphics.h> #include <ctype.h> #include <stdlib.h> #include <stdio.h> void main() { clrscr(); int gd = DETECT,gm,errorcode; //Requesting auto-detection. //Initializing graphics and local variables. initgraph (&gd, &gm, “d:\bc3\bgi”); //Path where graphics drivers are installed //Read result of initialization. errorcode = graphresult(); //An error occured. if (errorcode != grOk) { cout << … Read more

Program to change the foreground colors and draw circles on the screen

  #include <conio.h> #include <graphics.h> #include <stdlib.h> #include <stdio.h> void main (int) { int gdriver=DETECT,gmode,errorcode; //Requesting auto-detection. int midx,midy,x; //Initializing graphics and local variables. initgraph(&gdriver,&gmode,“d:\bc3\bgi”); //Reading result of initialization. errorcode=graphresult(); if(errorcode!=grOk) //An error occurred. { printf(“Graphics error occurred : %s \n”,grapherrormsg(errorcode)); printf(“Press any key to stop : “); getch(); exit(1); //Terminate the program due to … Read more

Program to enter velocity, acceleration and time and print final velocity using the formula : v = u + a * t

  #include <iostream.h> #include <conio.h> void main() { clrscr(); int v,u,a,t; cout << “Enter the velocity, acceleration, time as integers : ” << endl; cin>>u>>a>>t; v=u+a*t; cout << “The final velocity is ” << v << “.” << endl; getch(); }   This program takes in the velocity, acceleration and the time as a screen … Read more