B
bigcjr44
I have an assignment do tonite and I can not get it started. We are
learning about recursion. This is my assignment, and this is what I have
written, could someone please tell me what I am doing
wrong.................THANK YOU.......
ASSIGNMENT:
Demonstrate to the instructor the successful completion of each program
output. Have this sheet ready for instructor to sign. Hand to instructor
to receive credit.
Write a program that will read in an integer number
It will recursively show the conversion between the decimal number and the
Octal number (base 8).
Example program output:
Please enter the decimal number : 43
The decimal number 43 is 53 in octal
You must use a recusive function to produce the output. Using the output
stream to set output to octal is not acceptable.
CODE I HAVE WRITTEN: PLEASE HELP.................
#include <iostream.h>
using namespace std;
main()
{
int num, oct, idiv, irmdr;
{
cout<<"Please enter the decimal number : ";
cin>>num;
cout<<"The decimal number "<<num;
cout<<" is "<<oct<<" in octal";
displayOct(num);
}
void displayOct(int pnum)
{
int idiv, irmdr;
irmdr=pnum%2;
idiv=pnum/8;
if (idiv>0) displayOct(idiv);
}
return 0;
}
learning about recursion. This is my assignment, and this is what I have
written, could someone please tell me what I am doing
wrong.................THANK YOU.......
ASSIGNMENT:
Demonstrate to the instructor the successful completion of each program
output. Have this sheet ready for instructor to sign. Hand to instructor
to receive credit.
Write a program that will read in an integer number
It will recursively show the conversion between the decimal number and the
Octal number (base 8).
Example program output:
Please enter the decimal number : 43
The decimal number 43 is 53 in octal
You must use a recusive function to produce the output. Using the output
stream to set output to octal is not acceptable.
CODE I HAVE WRITTEN: PLEASE HELP.................
#include <iostream.h>
using namespace std;
main()
{
int num, oct, idiv, irmdr;
{
cout<<"Please enter the decimal number : ";
cin>>num;
cout<<"The decimal number "<<num;
cout<<" is "<<oct<<" in octal";
displayOct(num);
}
void displayOct(int pnum)
{
int idiv, irmdr;
irmdr=pnum%2;
idiv=pnum/8;
if (idiv>0) displayOct(idiv);
}
return 0;
}