Hi guys!
I have an assignment for my C++ programming course. The deadline is 2009/11/1 ! (I know it's too late, but plzzzz!!) I would really appreciate it if you could help me.
The problem is:
Write a program which calculates and prints the area and circumference of a circle with 2 functions.
THANKS A LOT !
alizee67 0 Newbie Poster
Recommended Answers
Jump to PostYou should use one function for calculating the area of a circle, and another function for calculating the circumference.
The equation for calculating the area of a circle is
A = (pi) * r^2
Where A is obviously the area and r is the radius.
Jump to PostBefore we 'should' help you, you should post some code before hand, so we can see that you put effort into your assignment.
Kontained gave you a good start btw.
Jump to PostCircumference and area are both out of scope in the main() function, and you need to pass in radius to the function. They should probably return floats
Jump to PostI missed it, but yours compiles because you declared them all as global variables. It works, but is not good practice for the purposes of clean coding: you should declare circumference, radius, etc within main and do the appropriate passing and returning.
All 16 Replies
Kontained 0 Light Poster
restrictment 91 Posting Whiz in Training
alizee67 0 Newbie Poster
restrictment 91 Posting Whiz in Training
alizee67 0 Newbie Poster
restrictment 91 Posting Whiz in Training
alizee67 0 Newbie Poster
restrictment 91 Posting Whiz in Training
alizee67 0 Newbie Poster
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
restrictment 91 Posting Whiz in Training
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
restrictment 91 Posting Whiz in Training
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
restrictment 91 Posting Whiz in Training
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
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.