|
-
April 16th, 2007, 09:09 PM
#1
Please Help Calling function
.
The whole assignment is so confusing it is creazy.
a. [4 points] Write a definition of function one so that it returns the sum of x and y if x is greater than y; otherwise, it should return x minus 2 times y.
b. [5 points] Write the definition of function two as follows:
1. Read a number and store it in z.
2. Update the value of z by adding the value of a to its previous value.
3. Assign the variable first the value returned by function one with parameters 6 and 8.
4. Update the value of first by adding the value of x to its previous value.
5. If the value of z is more than twice the value of x to its previous value, return z; otherwise, return 2 times first minus z.
c. Write a C++ program that test parts a and b. (Declare additional variables in the function main, if necessary)
Call function one and pass two parameter values: 4 and 5. Display the returned value from function one.
Input an integer number and double number assigned them to variables um and dec respectively.
Call function two and pass these two values. Display the returned value from function two.
MY CODE IS HERE
#include<iostream>
using namespace std;
int one(int, int);
double two(int x, double a);
int main()
{int num;
double dec;
return one(num,dec);
return two(num,dec);
//Write a C++ program that test parts a and b.
//(Declare additional variables in the function main, if necessary)
// Call function one and pass two parameter values: 4 and 5.
// Display the returned value from function one.
// Input an integer number and double number assigned them to variables num
// and dec respectively.
// Call function two and pass these two values. Display the returned
// value from function two.
return 0;
}
int one(int x, int y)
{
if (x>y)
return x+y;
else
return x-2*y;
}
double two(int x, double a)
{
int first;
double z;
cin>>z;
cout<<endl;
z= a+z;
first = one(6,8);
first =x+first;
if (z>2*first)
return z;
else
return 2*first -z;
}
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
|