Results 1 to 7 of 7
Dear all
I'm writing a C++ program including 2 routines where I need to pass result of one routine to another for further calculations. How to I proceed with it? ...
- 02-08-2008 #1Just Joined!
- Join Date
- Feb 2008
- Posts
- 3
Passing result of one routine to another
Dear all
I'm writing a C++ program including 2 routines where I need to pass result of one routine to another for further calculations. How to I proceed with it? Please help...
My program1.C is like this -
Code://program1: using namespace std; #include <iostream> #include <cstdlib> #include <cmath> int main () { float x1, y1, z1, x2, y2, z2, xa, ya, za, theta, omega; cout << "\nEnter Pt.1 X value\t"; cin >> x1; cout << "\nEnter Pt.1 Y value\t"; cin >> y1; cout << "\nEnter Pt.1 Z value\t"; cin >> z1; cout << "\nEnter Pt. 2 X value\t"; cin >> x2; cout << "\nEnter Pt.2 Y value\t"; cin >> y2; cout << "\nEnter Pt.2 Z value\t"; cin >> z2; xa = fabs(xr-xs); ya = fabs(yr-ys); za = fabs(zr-zs); theta = atan(za/(sqrt(xa*xa + ya*ya))); omega = atan(ya/xa); cout << "\ntheta = "<< theta; cout << "\nomega = "<< omega; cout << "\n\n"; (theta, omega) = program2(); // don't know if this is correct }Last edited by devils casper; 02-08-2008 at 12:31 PM. Reason: Added [code] .... [/code] tag.
- 02-08-2008 #2
When does your instructor say this assignment is due?
--
Bill
Old age and treachery will overcome youth and skill.
- 02-08-2008 #3Just Joined!
- Join Date
- Feb 2008
- Posts
- 3
This is not an assignment. I'm new to C++ and Unix and trying out to develop a software. Kindly reply if you have a solution.
Its easier to make fun than to help.
- 02-08-2008 #4
functions to a function
do you mean something like this?
void func(int&, int&);
void func2(void (*)(int&, int&), int&, int&);
where func2 contains func prototype as a parameter.
or
int func(int x);
int func2(int x);
int y = func2(func(45));
- 02-08-2008 #5
wje asked that question because this does sound like a homework assignment, and you gave us no context in which to work. It is against the forum rules to put up homework assignments, hence the question.
So then, I'm afraid I don't understand what you're trying to do. You have a function called program2, apparently. Are you trying to pass theta and omega into program2? What does program2 do? What parameters does it take?DISTRO=Arch
Registered Linux User #388732
- 02-08-2008 #6Precisely.wje asked that question because this does sound like a homework assignment, and you gave us no context in which to work. It is against the forum rules to put up homework assignments, hence the question.
Welcome! I hope we can help you. Cabhan has started you out with a question for which I'd like the answer as well. :)--
Bill
Old age and treachery will overcome youth and skill.
- 02-08-2008 #7Just Joined!
- Join Date
- Feb 2008
- Posts
- 3
Well! Cabhan and wje_lf
Thanx a lot for the elite advice from you. Your reactions/comments to my query have boosted my confidence in getting enormous help from this forum.
gerard4143
I sincerely appreciate a lot your direction. It helped.


Reply With Quote