|
-
Feb 13th, 2001, 08:19 PM
#1
Thread Starter
Member
OK today i desided no more hard math work and i made a program to increase my efficiancy.
calling a function that does stuff aint that easy like vb. please tell me what im forgetting.
Code:
#include <stdio.h>
#include <iostream.h>
const double Pi = 3.141592654;
char choice;
int main()
{
printf("a. Cylinder\n");
printf("b. Cone\n");
printf("c. Prism\n");
printf("d. Pyramid\n");
printf("--------------\n");
printf("x. Exit\n");
cin>>choice;
switch ( choice ){
case 'a':
LaSaCylinder();
break;
case 'x':
return 0;
};
};
//////////////////////////
//Cylinder Calculation ///
//////////////////////////
//LA = Lateral Area ///
//////////////////////////
//SA = Surface Area ///
//////////////////////////
void LaSaCylinder(int radius, int hieght, double LA, double SA);
{
cout << "What is the radius of the base?\n";
cin >> radius;
cout << "What is the height of the Cylinder?\n";
cin >> height;
LA = (2 * Pi * radius) * height;
SA = LA + (2 * (Pi * (radius^2)));
cout << LA << " is the Lateral area.\n";
cout << SA << " is the Surface area.\n";
};
this has been more work than i thought! m8's! Heres my craptacular error!
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ||||||||||||||
--------------------Configuration: Math - Win32 Debug--------------------
Compiling...
Math.cpp
D:\Ftp\BIN\Math\Math.cpp(21) : error C2065: 'LaSaCylinder' : undeclared identifier
D:\Ftp\BIN\Math\Math.cpp(35) : error C2373: 'LaSaCylinder' : redefinition; different type modifiers
D:\Ftp\BIN\Math\Math.cpp(36) : error C2447: missing function header (old-style formal list?)
Error executing cl.exe.
Math.exe - 3 error(s), 0 warning(s)
---------------------------------------------------------------------------------------
it just Got worse!
Last edited by factor777; Feb 13th, 2001 at 08:40 PM.
-
Feb 13th, 2001, 08:29 PM
#2
Frenzied Member
You don't include the return type when you're calling a function, otherwise it's a function declaration. I see people do this a lot, it must be confusing 
Code:
switch ( choice ){
case 'a':
LaSaCylinder();
break;
case 'x':
return 0;
};
Something like that will do it.
Harry.
"From one thing, know ten thousand things."
-
Feb 13th, 2001, 08:30 PM
#3
Frenzied Member
Incidentally, in case you hadn't noticed, that's just the same as in VB
Harry.
"From one thing, know ten thousand things."
-
Feb 13th, 2001, 08:38 PM
#4
Thread Starter
Member
ok its still guaking at me, i dont know what it wants.
i have been fixing repetitive things like this for an hour! it sucks.
oh well i need the experiance right? (i'll answer that) Right!
-
Feb 13th, 2001, 09:51 PM
#5
Fanatic Member
Forgive me if my technical grammar is not up to par in C++ but don't you have to have a function declaration if the function is written after the main() function, i.e.
Code:
#include <stdio.h>
#include <iostream.h>
const double Pi = 3.141592654;
char choice;
void LaSaCylinder(int radius, int hieght, double LA, double SA);
int main()
{
printf("a. Cylinder\n");
printf("b. Cone\n");
printf("c. Prism\n");
printf("d. Pyramid\n");
printf("--------------\n");
printf("x. Exit\n");
cin>>choice;
switch ( choice ){
case 'a':
LaSaCylinder();
break;
case 'x':
return 0;
};
};
//////////////////////////
//Cylinder Calculation ///
//////////////////////////
//LA = Lateral Area ///
//////////////////////////
//SA = Surface Area ///
//////////////////////////
void LaSaCylinder(int radius, int hieght, double LA, double SA);
{
cout << "What is the radius of the base?\n";
cin >> radius;
cout << "What is the height of the Cylinder?\n";
cin >> height;
LA = (2 * Pi * radius) * height;
SA = LA + (2 * (Pi * (radius^2)));
cout << LA << " is the Lateral area.\n";
cout << SA << " is the Surface area.\n";
};
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
Feb 14th, 2001, 07:40 AM
#6
Frenzied Member
Yeah, that too
Harry.
"From one thing, know ten thousand things."
-
Feb 14th, 2001, 02:30 PM
#7
Thread Starter
Member
-
Feb 14th, 2001, 05:49 PM
#8
Fanatic Member
A thing I noticed is you spelled 'height' 'hieght', hope that helps.
Alcohol & calculus don't mix.
Never drink & derive.
-
Feb 14th, 2001, 06:23 PM
#9
Fanatic Member
I tried to make it work, this is what I did:
Code:
#include <iostream.h>
const double Pi = 3.1415926535897932384626433832795;
char choice;
void LaSaCylinder();
int main()
{
cout<<"a.\tCylinder\n";
cout<<"b.\tCone\n";
cout<<"c.\tPrism\n";
cout<<"d.\tPyramid\n";
cout<<"--------------\n";
cout<<"x.\tExit\n";
cin>>choice;
switch (choice)
{
case 'a':
LaSaCylinder();
break;
case 'x':
return 0;
}
}
//////////////////////////
//Cylinder Calculation ///
//////////////////////////
//LA = Lateral Area ///
//////////////////////////
//SA = Surface Area ///
//////////////////////////
void LaSaCylinder()
{
int radius, height, LA, SA;
cout << "What is the radius of the base?\n";
cin >> radius;
cout << "What is the height of the Cylinder?\n";
cin >> height;
LA = (2 * Pi * radius) * height;
SA = LA + (2 * (Pi * (radius^2)));
cout << LA << " is the Lateral area.\n";
cout << SA << " is the Surface area.\n";
}
I forgot to add, when you were writing the actual function (don't know what it's called) you put some semicolons between the parenthesis and the openign bracket, and that caused the old-style function thing. Hope this helps!
Alcohol & calculus don't mix.
Never drink & derive.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|