How i solve this problem ?? i try, but i don't know wts the wrong??

A.Write the defintion of function one so that it returns the sum of x and y if x greater than y, it sholud return x mines 2 times y.
B.Write the defintion of function two sa fllos: 1.read a number and stor it in z. 2.Update the value of z by adding the value of a to its previous value.
3.Assign the varable 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 pervious value.
5.If the value of z is more thab twice the value of first. return z; otherwise return 2 times first mines z.
C.Write a c++ program that tests parts a and b. (Declear additional varables in the function main, if necessary).

``````# include <iostream>
using namespace std;
int one (int x, int y)
double two (int x, double a)

int main ()

{
int num;
double dec;

cout<<"please enter two integers numbers: ";
cin>>x>>y;

cout<<"please enter a double number: ";
cin>>a;

num = int one (int x, int y);

dec = double two (int x, double a);

first = int one (int x=6, int y=8)

return 0;
}

int one (int x, int y)

{
if (x > y)
return x + y;

else
return x= y - 2;
}

double two (int x, double a)

{
int first;
double z;

cout<<z += a;

cout<<first += x;

if (z > first * 2)
return z;

else
return (first * 2) - z;
}``````
4
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by jesseb07

``````//Write the defintion of function one so that it returns the sum of x and y if x greater than y, it sholud return x mines 2 times y.
int one (int x, int y)

{
//   if (x > y)
if (x <= y)
return x + y;
else
//      return x= y - 2;
return (x - 2) * y;
}``````

I suggest you recompare the instructions to your functions!

Look up how to make and use functions.
By the way, use code tags in your post.
Good luck.

you will also need to define x, y, a, and first before you can use them in main()

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.