Write the following functions
draw_circle – draws a circle
draw_intersect – draws intersecting lines
draw_base – draws a base line
draw_triangle – draws triangle using intersecting lines and base line
draw_rectangle – using baseline and parallel lines
skip_5_lines – skips five lines between each picture below
Write a program that uses the above functions to draw the following:
A rocket ship (triangle over rectangle over intersecting lines)
A male stick figure (circle over rectangle over intersecting lines)
A female stick figure standing on the head of a male stick figure

id like to do this but dont know where to start

Recommended Answers

All 11 Replies

Understanding you problem domain in the first step in solving a problem. If the above assignment would have been in Java it would have been simple matter of using Applet to draw the lines and circles but as it is in C you need to use an external library to draw the circles and other figures.

Search the net for the logic for drawing the above figures and tackle the problem in small chunks. Come up with a rough plan and try the flowchart and algorithm approach.

I would have given you the code but that would have made the other members here angry ( i already have got a bad post trying to help out a newbie) and also it would do you more harm than good (seriously).

If you feel you lack the required C knowledge consider falling back to the basics and coming back to the project after you have done your studies.

HOpe it helped, bye.

man i could use the code or part of it to strat then i can figure it out i got some many classes i dont have time to look things up

Its unlikely you are being asked to write any of that with very advanced techniques such as using a graphics library, unless you are actually taking such a course. If this is your first year of programming then just use standard console-mode print statements to create small circles, triangles and lines. First I'd work on learning how to display a straight line. When you get that idea down, then work on learning how to draw a triangle (uses several nested loops). Once you learn that the rest of the requirements should be pretty straight forward.

>>i dont have time to look things up
Then you might consider dropping a class or two to free up some time because computer programming is very very time consuming. Also, stop going to those beer parties might help too :)

lol i cant drop classes can you tell me were to look or help with starting the code

>>lol i cant drop classes
I guess you will be burning a lot of midnight oil! Better start reading, studying and practicing all those exercises at the end of the chapters. They are there for a purpose -- to help you learn.

Here is a C starter program.

#include <stdio.h>

int main()
   // put your code here

   return 0;
commented: your an asshole +0

hahaha funny asshole

commented: Don't let the door hit you in the ass on your way out +0

hahaha funny asshole

:mrgreen: :mrgreen:

hahaha funny asshole

Hey that is very uncalled for and for your kind information Mr. Ancient Dragon is a senoir member of this forum. Take back your stmt and apologize this instant.

Oh it looks like Mr. Dragon is comfortable with this so its also ok with me.

I would do it this way (I am not an good programmer I and I only code C++, So I can only give you and Idea)

First make the protoytpes:

draw_circle(int x,int y,float diameter)
draw_intersect/*I don't understand what they mean with this/*
draw_base(int x1, int y1,int x2,int y2) /*I assume they mean an normal line with this/*
draw_triangle(int x1,int y1,int x2,int y2,int x3,int y3);
draw_rectangle(int x1,int y1,int x2,int y2);
skip_5_lines/*To don't understnad this one/*

Then just make one extra function: draw_point(int x,int y); I don't feel like doing the math on this one, but figure out how to draw an line using the draw_point function + loop(s).

Then the draw_rectangle is just drawing 4 lines.
The the draw_triangle is just drawing 3 lines.
Draw_circle should be done with an formula + draw_point.

You see that you can just fill all in using themself, now you just need to find an way to use an Graphic library to activate draw_point.

You might want to make draw_point an inline function, since it is used so much.

I hope this helped

As much as you may not like to hear it, you've been given good advice. Essentially you have four choices:

1) Use ASCI art (use what characters are available in the ASCI character set). It will probably help to have an ASCI table to look up the available characters and you will need to be (or become) very comfortable with control loops and output statements, but that's about all it will take.

2) Use a non standard, but widely used graphics library such as OpenGL. For example, to use OpenGL you can search Google to find a download site, set it up on your computer, read an online tutorial about how to use OpenGL and away you go. Obviously, obtaining, setting up and learning how to use a graphics library to get the task done will be a bigger task than using ASCI art.

3) You can continue trying to mooch code for the project off someone. Don't be too surprised if your efforts are met with some resistance if this is what you choose to do.

4) Clearly the easiest option would be to elect not to do the extra credit work.

>>Obviously, obtaining, setting up and learning how to use a graphics library to get the task done will be a bigger task than using ASCI art

And probably way too much for a first year student who doesn't even know how to draw a staight line using normal console output! OpenGL and other similar graphics programs require pretty advanced programming skills.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.