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
Other than in a for statement, when is the comma operator used?
Example : int i,j; i=(10,20,30,40); j=10,20,30,40; printf("%d",i); printf("%d",j); // in this program output of i will be 40 and j will be 10 // In interviews you can face such type of comma operator related questions.
Sanjay

Program to accept a list of elements and find the maximum number in the list. 

 

The logic will be 1. Create an array of the desired type 2. Sort the array in the descending order 3. Fetch the first elemnet from the array, this will be the maximum element in that array. Now use...
Lavanya
0 0
8
What are pointers in C language?
Hi Imran, Hope you are doing good. Are you looking for short answer or long answer? :) Pointers in C are variables that store memory addresses. They point to the location of another variable, allowing...
Imran
0 0
7
any one can teach me c++
Yes of course i can give you online classes
Bhuvanesh

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

Ask a Question

Related Lessons

Java and C trainer
Always think any conspect with real-time example like Object -- object must have states and behaviour then only we will call that thing is Object like fan is Object (rotating,color)

Why we need to learn Programming languages?
Language is medium for communication. If two parties like to communicate or exchange the thoughts they must know a language. Language should be understandable by both the Parties. For example A wants to...

Set 0 To Kth Bit In A Variable
The following code snippet Set 0 to Kth Bit in an variable #include int UnsetBitValue(int n, int k);int main(){ printf("%d\n\n",UnsetBitValue(255,6)); return 0;}// Set kth bit to zeroint UnsetBitValue(int...

C PROGRAM FOR GENERATING SOUND
#include<stdio.h> #include<conio.h> #include<dos.h> void main() { sound(3000); // sound function have single parameter , this parameter we put integer value its generating...

V. Muthu Ganeshan

0 0
0

Tress And Its Traversal
Depth First Traversals:(a) Inorder (Left, Root, Right) : 4 2 5 1 3(b) Preorder (Root, Left, Right) : 1 2 4 5 3(c) Postorder (Left, Right, Root) : 4 5 2 3 1 Trees are one of the data structures like...

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