Hey guys, new to the forum and already have a question haha. I'm trying to create a program that will do as follows.

Write a function called breakThree that will accept a 3 digit integer and returns each of the numbers individually. This function has to have four paramaters. The first parameter is the three digit number to break apart. Parameters 2 through 4 are passed by reference and will be used to return each of the numbers back to main.

If it is not a three digit number the breakThree function should return false. If it is a three digit number the breakThree function should break the number apart, and store each of the numbers in the parameters passed by reference.

In main you should get the number from input and then output each of the numbers on a separate line

so if the number was 365 each line should be as follows:

3

6

5

Also, Im trying not to use any global variables, cin or cout in the breakThree function.

Write a function called breakThree that will accept a 3 digit integer and returns each of the numbers individually. This function has to have four paramaters. The first parameter is the three digit number to break apart. Parameters 2 through 4 are passed by reference and will be used to return each of the numbers back to main.

If it is not a three digit number the breakThree function should return false. If it is a three digit number the breakThree function should break the number apart, and store each of the numbers in the parameters passed by reference.

In main you should get the number from input and then output each of the numbers on a separate line

so if the number was 365 each line should be as follows:

3

6

5

Also, Im trying not to use any global variables, cin or cout in the breakThree function.

Last edited on

this is what i have so far.

#include <iostream>

using namespace std;

void breakThree(int a, int b, int c, int d);

int main()

{

cout << "enter a three digit number" << endl;

int a;

cin >> a;

cout << "here are your numbers" << endl;

cout << void breakThree(b) << endl;

cout << void breakThree(c) << endl;

cout << void breakThree(d) << endl;

return 0;

}

void breakThree (int a, int b, int c, int d)

{

int b, c, d;

d = a % 10;

c = (a / 10) % 10;

b = a / 100;

return a, b, c, d;

}

#include <iostream>

using namespace std;

void breakThree(int a, int b, int c, int d);

int main()

{

cout << "enter a three digit number" << endl;

int a;

cin >> a;

cout << "here are your numbers" << endl;

cout << void breakThree(b) << endl;

cout << void breakThree(c) << endl;

cout << void breakThree(d) << endl;

return 0;

}

void breakThree (int a, int b, int c, int d)

{

int b, c, d;

d = a % 10;

c = (a / 10) % 10;

b = a / 100;

return a, b, c, d;

}

Topic archived. No new replies allowed.