| | |
Stuck writing a Function
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2004
Posts: 6
Reputation:
Solved Threads: 0
I have to write a function to find the circumference of a circle. I am having problems cause I dont have any idea how to do that. I know ya'll like to have some kind of showing of my own program the only thing is that I dont understand what to do or where to start. My teacher is no help. I dont like the way he teaches. Maybe someone here can get me to understand a function with an example or something.
My program started
#include<iostream.h>
void my_sum(int r)
{
float sum;
sum = 2*3.14*r;
cout<<"The circumference of a circle is "<<sum<<"."<<endl;
}
int main()
{
Im stuck. I dont think this is even right. I dont know what I am doing. Please someone help.
Kelly
My program started
#include<iostream.h>
void my_sum(int r)
{
float sum;
sum = 2*3.14*r;
cout<<"The circumference of a circle is "<<sum<<"."<<endl;
}
int main()
{
Im stuck. I dont think this is even right. I dont know what I am doing. Please someone help.
Kelly
Try compiling and running the code you are developing.
#include<iostream> using namespace std; void my_sum(int r) { float sum; sum = 2 * 3.14 * r; cout << "The circumference of a circle is " << sum << "." << endl; } int main() { my_sum(1); return 0; }
•
•
Join Date: Nov 2004
Posts: 13
Reputation:
Solved Threads: 1
•
•
•
•
Originally Posted by kellyandtopher
Maybe someone here can get me to understand a function with an example or something.
are you having trouble understanding the concept of functions?
if thats the case then a quick example would be something like this
C++ Syntax (Toggle Plain Text)
int addone(int x) { return x+1; } int main() { int z = 5; z = addone(z); z = addone(z); }
hope it helped...
•
•
Join Date: Nov 2004
Posts: 108
Reputation:
Solved Threads: 3
Join me on IRC:
Server: irc.daniweb.com
Channel: #C++
Chat Via:
http://daniweb.com/chat/minichat.php
or
Your favorite IRC client.
Server: irc.daniweb.com
Channel: #C++
Chat Via:
http://daniweb.com/chat/minichat.php
or
Your favorite IRC client.
![]() |
Similar Threads
- stuck on a member function for a class (C++)
- Need help writing a function (Visual Basic 4 / 5 / 6)
Other Threads in the C++ Forum
- Previous Thread: Audio File Matching Program
- Next Thread: Which components of Visual C++ should i install
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll email encryption error file forms fstream function functions game generator getline givemetehcodez graph homeworkhelper iamthwee ifstream image input int java lazy lib loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






