Write a C program to implement Rotation of wheel in Graphics

By | 02.12.2016

Implement Rotation of wheel in Graphics


Write a C program to implement Rotation of wheel in Graphics. Here’s simple C program to implement Rotation of wheel in Graphics in C Programming Language.


Below is the source code for C program to implement Rotation of wheel in Graphics which is successfully compiled and run on Windows System to produce desired output as shown below :


SOURCE CODE : :


 

#include<stdio.h>
#include<graphics.h>
#include<math.h>
#include<conio.h>
#include<dos.h>
 
int xc=50,yc=200,r=35;
int x[15],y[15];
void drawcircles()
{
        setcolor(YELLOW);
        circle(xc,yc,r);
        circle(xc,yc,r+5);
}
void main()
{
        double angle=0,theta;
        int i,a;
        int gd=DETECT,gm;
        initgraph(&gd,&gm,"..\\bgi");
        a=xc+r;
        while(!kbhit())
        {
                while(a<=630)
                {
                        theta=M_PI*angle/180;
                        cleardevice();
                        drawcircles();
                        for(i=0;i<18;i++)
                        {
                                theta=M_PI*angle/180;
                                x[i]=xc+r*cos(theta);
                                y[i]=yc+r*sin(theta);
                                angle+=20;
                                line(xc,yc,x[i],y[i]);
                        }
                        angle+=2; xc+=2; a=xc+r;
                        delay(50);
                }
                xc=50;  r=35; a=xc+r;
        }
        getch();
        closegraph();
}

Above is the source code for C program to implement Rotation of wheel in Graphics which is successfully compiled and run on Windows System.The Output of the program is shown above .

If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section.We will try our best to reach up to you in short interval.


Thanks for reading the post….

0 0 votes
Article Rating
Category: C Programming Graphic Programs Tags:

About Tunde A

My name is Tunde Ajetomobi, a Tech Enthusiast and Growth Hacker. I enjoy creating helpful content that solves problem across different topics. Codezclub is my way of helping young aspiring programmers and students to hone their skills and find solutions on fundamental programming languages.

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments