C++ Graphics Program to Draw Space,Solar System,Moon and Stars and Night Sky in Command Line

Here, I wish to explain the topic about “C++ Graphics Program to Draw Space,Solar System,Moon and Stars and Night Sky in Command Line”. Let’s see the possibilities to perform this task below.

C++ Graphics Program to Draw Space,Solar System,Moon and Stars and Night Sky in Command Line

C++ Graphics Program to Draw Space,Solar System,Moon and Stars and Night Sky in Command Line

Source Code

#include <dos.h>
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <math.h>
// vp(int x,int tc,int bk,char *text);

int main(void)
{

   /* request auto detection */
   int gdriver = DETECT, gmode, errorcode;

   /* initialize graphics and local
      variables */
   initgraph(&gdriver, &gmode, "c:\turboc3\bgi");

   /* read result of initialization */
   errorcode = graphresult();
   if (errorcode != grOk)  /* an error
       occurred */
   {
      printf("Graphics error: %sn", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();
      exit(1); /* terminate with an error  code */
    }



int x=300,y=300;
moveto(x,y);
   float r=170;
  {
  for(float i=1;;i=i+0.05)

    {
  setcolor(random(15));
 int MaxX=getmaxx();  int MaxY=getmaxy();
for (int zi=0 ;zi<10;++zi)
{
circle(random(MaxX), random(MaxY),1 );
putpixel(random(MaxX), random(MaxY),random(15) );
}
setcolor((12));  if(kbhit())  exit(0);
int b=y+r*cos(i);int a1=x+r*sin(i*2);int b2=y+r*(cos(i)/8);line(a1,b,a1,b2);
  printf("n");
  delay(10);
   }
 }
}//_main

Final Words

We hope this article “C++ Graphics Program to Draw Space,Solar System,Moon and Stars and Night Sky in Command Line” will be useful to you. If you face any issues please let me know via the comment section. Share this article with other C/C++ developers via social networks.

Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment