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 can I develop my C language?
Developing your proficiency in the C programming language involves a combination of learning, practice, and real-world application. Here are some steps to help you enhance your skills in C: Learn the...
Himanshu
0 0
5
Can you suggest me some books for learning C?
"letus c" for c programming yashwant kanetkar
Yamun
What is the benefit of using enum to declare a constant?
ENUMS.. Can give numerical values for Sunday, Monday,... Easy to use in coding... Makes the program more readable/ understandable, than using 1,2,3.. Etc.
Sita
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

Working with C/C++ applications
Inorder to learn C and C++ programming languages one can work with various editors available.To name a few are the most popular one is turbo c++, DEV C++, Eclipse, NetBeans. Here are the screen shots...

Compiler vs Interpreter
Compiler Interpreter Convert all the code into binary format and execute. Convert one statement at a time and execute, then Convert next statement and execute. After conversion, source...

Some Tricky Questions in C
Can you write two functions in which one executes before main function and other executes after the main function? #pragma startup #pragma exit Where, priority is optional integer value.For user priority...

Can we store different data types in a stack?
Yesterday, one of my Facebook friend asked me this question. My answer is "yes", and in this post I will discuss how could we do this.I am a great supporter of working with unions and I will be using union...

Array vs Linked List
Array Linked List Accessing element is easy. Accessing element is difficult compare to Array. Easy to use. Difficult to use. Memory is Fixed size. Memory is variable size. If...

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 >

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 >

Business Process outsourcing (BPO) services can be considered as a kind of outsourcing which involves subletting of specific functions associated with any business to a third party service provider. BPO is usually administered as a cost-saving procedure for functions which an organization needs but does not rely upon to...

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