CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

# Thread: [RESOLVED] join to piece of a program

1. Member
Join Date
May 2017
Posts
182

## [RESOLVED] join to piece of a program

hello there . I have a program that is not displaying any result . I would appreciate your help . SO this is my code below
to be clear I should do this :

a) Calculate the integer part of the quotient when integer a is divided by integer b.
b) Calculate the integer remainder when integer a is divided by integer b.
c) Use the program pieces developed in (a) and (b) to write a function that inputs an
integer between 1 and 32767 and prints it as a series of digits, each pair of which is
separated by two spaces. For example, the integer 4562 should print as follows:
4 5 6 2

this is my code where I should join part a and part b to split digits :

Code:
``` #include < iostream >
using namespace std;

int quotient ( int a , int b ) // first piece.
{
return a / b ;
}

int remainder ( int a, int b ) // second piece.
{
return a % b;
}

void split ( int a ) // problem probably with joining them
{
int div = 10000; // since the max number of digits is 5.

int sep;

bool lastdigit = false; // it will stop on last non zero digit to the left.

while ( div != 1 )
{
sep = quotient( a , div );

if ( lastdigit == false && sep == 0 ) // if 0 do nothing.
{

}
else
{
lastdigit = true;
cout << sep << "  ";
}

a = remainder( a , div  );
div = div / 10;
}

cout << a << endl;
}

int main ()
{
int x;

cout << "\nThis program will split a number of your choice between the following range : \n " << endl;

do {
cout << "\nPlease enter an interger number X ( 1 < X < 32767 ) :\n " << endl;
cin >> x;

}while ( x < 1 && cout << "\nSorry wrong input!\n" ||  x > 32767 && cout << "\nSorry wrong input!\n" );

void split ( int x );

cout << "\n";
system ( "pause" );
return 0;

}```

2. ## Re: join to piece of a program

Code:
`void split ( int x );`
Do you mean to declare a function split here?

3. Member
Join Date
May 2017
Posts
182

## Re: join to piece of a program

Oh I see I have t pit split ( x ) ; I didnt notice that . thx
Last edited by david16; June 30th, 2017 at 06:52 AM.

4. Member
Join Date
May 2017
Posts
182

## Re: join to piece of a program

I have another question on single character validation can I ask about it ??

5. ## Re: join to piece of a program

Originally Posted by david16
I have another question on single character validation can I ask about it ??

6. ## Re: [RESOLVED] join to piece of a program

Last edited by 2kaud; June 30th, 2017 at 01:14 PM.

7. Member
Join Date
May 2017
Posts
182

## Re: [RESOLVED] join to piece of a program

I'll post a new thread please join on it. this name "join to piece of a program 2"

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•