UrbanPro

Learn C Language from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Can anybody provide me error free coding for graphic program in C??? Animated Smiley program Rotating Fan progran Sunrise program

Asked by Last Modified  

Follow 0
Answer

Please enter your answer

Project Development: Custom Training and Software based Project Development Company

#include graphics.h #include conio.h #include stdlib.h #include dos.h main() { int gd = DETECT, gm,area,temp1,temp2,left =25,top=75; void *p; initgraph(&gd,&gm,”C:\\TC\\BGI”); setcolor(YELLOW); circle(50,100,25); setfillstyle(SOLID_FILL,YELLOW); floodfill(50,100,YELLOW); setcolor(BLACK); setfillstyle(SOLID_FILL,BLACK); fillellipse(44,85,2,6); fillellipse(56,85,2,6); ellipse(50,100.205,335,20,9); ellipse(50,100.205,335,20,10); ellipse(50,100.205,335,20,11); area...
read more
#include graphics.h #include conio.h #include stdlib.h #include dos.h main() { int gd = DETECT, gm,area,temp1,temp2,left =25,top=75; void *p; initgraph(&gd,&gm,”C:\\TC\\BGI”); setcolor(YELLOW); circle(50,100,25); setfillstyle(SOLID_FILL,YELLOW); floodfill(50,100,YELLOW); setcolor(BLACK); setfillstyle(SOLID_FILL,BLACK); fillellipse(44,85,2,6); fillellipse(56,85,2,6); ellipse(50,100.205,335,20,9); ellipse(50,100.205,335,20,10); ellipse(50,100.205,335,20,11); area = imagesize(left,top,left+50,top+50); p = malloc(area); setcolor(WHITE); settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2); outtextstyle(155,451,”Smiling face Animation”); setcolor(BLUE); rectangle(0,0,639,449); while(!kbhit()) { temp1 = 1 + random(588); temp2 = 1 + random(380); getimage(left,top,left+50,top+50,p); putimage(temp1,temp2,p,xor_put); delay(100); left = temp1; top = temp2; } getch(); closegraph(); return 0; } Happy coding! Enjoy! 2. Rotating Fan program #include graphics.h //for graphics #include stdio.h //standard input/output #include string.h //string function #include conio.h //console input output #include math.h //math calculation #define PI 3.14 //value constant pi=3.14 char speed[4]; //array declaration for speed int theta=0,change=1,temp=0,ch; float x,y,r=100; void main() { int gd=DETECT,gm; initgraph(&gd,&gm,"c:\\tc\\bgi"); //path where ur BGI file is stored strcpy(speed,"on 1"); outtextxy(200,20,"Working Fan"); outtextxy(150,50,"Use number 0 1 2 3 to change fan speed"); outtextxy(475,375,"Fan Speed"); fan: do { cleardevice(); outtextxy(200,20,"Working Fan"); outtextxy(150,50,"Use number 0 1 2 3 to change fan speed"); outtextxy(475,375,"Fan Speed"); if(kbhit()) { ch=getch(); if(ch=='0') { rectangle(495,395,535,410); floodfill(515,405,15); temp=1; } if(ch=='1') { strcpy(speed,"on 1"); change=1; } else if(ch=='2') { strcpy(speed,"on 2"); change=3; } else if(ch=='3') { strcpy(speed,"on 3"); change=18; } } outtextxy(500,400,speed); circle(320,240,(r/12)); circle(320,240,(r/6)); circle(320,240,(r/4)); x=r*(cos((PI * theta)/180)); y=r*sin((PI * theta)/180); line(320+(x/4),240+(y/4),320+(1.6*x),230+(1.6*y)); /*draw the line for fan*/ line(320+(x/4),240+(y/4),320+(1.6*x),250+(1.6*y)); line(320+(1.6*x),230+(1.6*y),320+(1.6*x),250+(1.6*y)); x=r*cos((PI *(theta+120))/180); y=r*sin((PI *(theta+120))/180); line(320+(x/4),240+(y/4),320+(1.6*x),230+(1.6*y)); line(320+(x/4),240+(y/4),320+(1.6*x),250+(1.6*y)); line(320+(1.6*x),230+(1.6*y),320+(1.6*x),250+(1.6*y)); x=r*cos((PI * (theta+240))/180); y=r*sin((PI * (theta+240))/180); line(320+(x/4),240+(y/4),320+(1.6*x),230+(1.6*y)); line(320+(x/4),240+(y/4),320+(1.6*x),250+(1.6*y)); line(320+(1.6*x),230+(1.6*y),320+(1.6*x),250+(1.6*y)); if(temp!=1) delay(36/change); else { ch=getche(); if(ch=='\r') exit(0); if(ch=='0') temp=1; if(ch=='1') //for speed { strcpy(speed,"on 1"); temp=0; change=1; } else if(ch=='2') { strcpy(speed,"on 2"); temp=0; change=3; } else if(ch=='3') { strcpy(speed,"on 3"); temp=0; change=18; } else { strcpy(speed,"off!"); temp=1; } } if(theta==360) theta=0; theta++; } while(temp==0); goto fan; } 3. Sunrise program:- #include graphics.h #include conio.h #include stdio.h void main() { int gd=DETECT,gm; int i,j,k,t,q; float x,y; initgraph(&gd,&gm,"c:\\tc\\bgi"); setcolor(2); rectangle(0,0,getmaxx(),getmaxy());  setcolor(2);  i=0; for(t=0;t getmaxx();t+=120) { line(t,250,t+60,170); line(t+60,170,t+120,250); } line(0,400,getmaxx(),350); setfillstyle(11,CYAN); floodfill(2,420,2); setfillstyle(4,LIGHTGREEN); floodfill(1,300,2); i=0; while(i!=150) { setcolor(BLACK); setfillstyle(SOLID_FILL,BLACK); fillellipse(k,j,30,30); setfillstyle(SOLID_FILL,LIGHTRED); fillellipse(170+i,235-i,30,30); j=235-i; k=170+i; i++; setcolor(2); for(t=0;t getmaxx();t+=120) { line(t,250,t+60,170); line(t+60,170,t+120,250); } setfillstyle(1,GREEN); floodfill(202,200,GREEN); delay(25); } for(i=36;i 80;i++) for(j=0;j =360;j+=20) { x=319+i*cos(((float)j*3.14)/180); y=86+i*sin(((float)j*3.14)/180); putpixel(x,y,LIGHTRED); delay(1); } getch(); } read less
Comments

Tutor

It's all the game of pointers in C. That is very easy task. But you looking for new job you should aware the technology.
Comments

Please consider giving more details,as to where you want to use this program.
Comments

Computer trainer

Upgrade yourself to C# , the C & graphics packages work only for DOS mode which is rare today. Explore the entire windowing using C#
Comments

Freelance technical trainer / consultant (Embedded systems, Automation / Scripting) : C, Linux, Embedded systems, python, perl, tcl

Requirements can be elaborated?
Comments

Computer Language Expert

DO you want to learn C graphics? or just want these codes?
Comments

Advance C-Embedded

mail id please
Comments

Tutor

#include stdio.h #include conio.h #include graphics.h void main() { int gd=DETECT, gm; clrscr(); initgraph(&gd,&gm,"C:\\TurboC3\\bgi"); circle(200,200,20); circle(180,180,5); circle(220,180,5); arc(190,210,45,135,10); getch(); } copy past this code into notepad and than save it by (.c...
read more
#include stdio.h #include conio.h #include graphics.h void main() { int gd=DETECT, gm; clrscr(); initgraph(&gd,&gm,"C:\\TurboC3\\bgi"); circle(200,200,20); circle(180,180,5); circle(220,180,5); arc(190,210,45,135,10); getch(); } copy past this code into notepad and than save it by (.c extension) at C:\TurboC++\Disk\TurboC3\BIN (change in header file and used less than and greater than sign because this site not allowed this characters) Tool- Turbo c++ enjoy... read less
Comments

View 6 more Answers

Related Questions

How do I write code in C programming that will invert a string like "Welcome to programming" to “gnimmargorp ot emocleW”?
void main() { char msg = "Welcome to Programming"; char str; int i = 0, j = 0; clrscr(); while (msg != '\0') { if (msg != ' ') { str = msg; j++; ...
Mukul
What is the importance of pointers? People stress more on them. Why they are useful actually what is their importance?
Importance of pointers:- Pointers are used in situations when passing actual values is difficult or not desired. To return more than one value from a function. They increase the execution speed. The...
Pati
Is C programming the best for beginners?
Yes, it is good to start with C so that other programming would be easy to understand
Amit
0 0
7
How do I learn C programming effectively? What is the best book?
C: The Complete Reference is written by Herbert Schildt is one of the best book for beginners
Sk
0 0
7

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Program to swap the value of two variables without using third variable(simplest way)...
int main() { int a=10,b=20; printf("values of a before swap ="%d,a); printf("values of b before swap ="%d,b); a=a+b; b=a-b; a=a-b; printf("******************"); printf("values of a after swap...

C Language
To get help in C window (for keywords, functions) press Alt +F1.To delete a single line , use the shortcut key CTRL +Y.If you got error about the path when you execute a C pgm, check the Options menu =>Directories.
T

Thilagam S.

0 0
0

Static and dynamic libraries
A library is a package of code that is meant to be reused by many programs. A static library (also known as an archive) consists of routines that are compiled and linked directly into your program. When...

Some interview questions for freshers on C language
Q1. What are the two forms of #include? There are two variants of #include. The one is #include and the other one is #include”file”. In general the first form that is #include is used to...

Find out the Output of the following with reason and get C Language Training fess less by 10%
1. void main() { clrscr(); printf(5+"Beautifull"); getch(); } 2. void main() { int a=50; clrscr(); ...

Recommended Articles

Lasya Infotech is a Hyderabad based IT training institute founded in 2016 by O Venkat. Believing in his innovation, passion and persistence and with a diverse blend of experience, he started his brainchild to deliver exemplary professional courses to aspiring candidates by honing their skills. Ever since the institute envisions...

Read full article >

Brilliant Academy is one of the reputed institutes for B.Tech tuition classes. This institute is specialised in delivering quality tuition classes for B.E, Engineering - all streams and Engineering diploma courses. Incorporated in 2012, Brillant Academy is a brainchild of Mr Jagadeesh. The main motto of the academy is to...

Read full article >

Almost all of us, inside the pocket, bag or on the table have a mobile phone, out of which 90% of us have a smartphone. The technology is advancing rapidly. When it comes to mobile phones, people today want much more than just making phone calls and playing games on the go. People now want instant access to all their business...

Read full article >

Information technology consultancy or Information technology consulting is a specialized field in which one can set their focus on providing advisory services to business firms on finding ways to use innovations in information technology to further their business and meet the objectives of the business. Not only does...

Read full article >

Looking for C Language Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for C Language Classes?

The best tutors for C Language Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn C Language with the Best Tutors

The best Tutors for C Language Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more