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 try to remember the coding in C language?
One shouldn't try to remember the coding. The right approach is to understand the logical solution to the problem.
Chinmayee
0 0
5
What is #line used for?
# is a preprocessor directive. so it is used in the c program by two way. 1. such as #include stdio.h In this line to read all the library function of stdio.h before processing the program. 2. # define...
Pradeep
Are C and C++ a prerequisite for learning Java?
yes..syntax of java is same as a c and c++..so it the advantage if you know any one of these.
Mrunal
0 0
5
What is C language?
C is a general-purpose, procedural programming language that was developed in the early 1970s by Dennis Ritchie at Bell Labs. It is a low-level language, which means it provides a relatively simple and...
Vikram
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

What Are IT Industries Performance Metrics?
1. Outstanding Expectation: Eligible to get Promotion easily and good salary hike. Always preferrable to go abroad. 2. Exceed Expectation: Can get Promotion as per schedule of company with good salary...

C Program-Prime Number
/*WAP to print a number entered by the user is prime or not*/ //Header files #include<stdio.h>#include<conio.h> //Main function void main(){ int num,i; //Function for clearing screen clrscr();...
S

C Program to print Block Letter and Small Case Alphabets using C
/* WAP to print Block Letter and Small Case Alpahbets using C*/ //Hint:use ascii code(value) to print #include#include void main(){ int i; clrscr(); //Block Letters Alphabets printf("Block Letters Alphabets\n");...
S

Basics Of C And C++
C++ is powerful, highly flexible, and adaptable programming language that allows software engineers to organise and process information quickly and effectively. But this high-level language is relatively...

Memory Layout of C Programs
A typical memory representation of C program consists of following sections. Text Segment: A text segment, also known as a code segment or simply as text, is one of the sections of a program in an object...

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