Hello,
I am receiving the following error: error C2065: 'to_binary' : undeclared identifier
while running the code below.
If anyone can help I'll appreciate it?
Thank you,
Tukeind
// File: fractal.cxx
// A demonstration program for the random_fractal function from Chapter 9.
#include <cassert> // Provides assert
#include <cstdlib> // Provides EXIT_SUCCESS
#include <iostream.h> // Provides cin, cout
#include "useful.h" // From Appendix H. Provides random_real, display
//using namespace std;
// PROTOTYPE for the function used in this demonstration program.
void random_fractal
(double left_height, double right_height, double width, double epsilon);
// Precondition: width and epsilon are both positive.
// Postcondition: The function has generated a random fractal from a line
// segment. The parameters left_height and right_height are the heights of the
// two endpoints of the line segment, and the parameter width is the segment's
// width. The generation of the random fractal stops when the width of the
// line segments reaches epsilon or less.
// Method of displaying the output: The height of the right endpoint of
// each line segment in the random fractal is displayed by calling the
// function display(...).
int main( )
{
cout << "The decimal number 10 equals ";
to_binary( 10 );
cout << " binary." << endl;
cout << "The decimal number 100 equals ";
to_binary( 100 );
cout << " binary." << endl;
cout << "The decimal number 1000 equals ";
to_binary( 1000 );
cout << " binary." << endl;
cout << "The decimal number 10000 equals ";
to_binary( 10000 );
cout << " binary." << endl;
return EXIT_SUCCESS;
}
void to_binary(int number)
{
if( number == 10)
return;
to_binary( number / 2);
cout << number % 2;
}
2 4476
Hi,
You have to add the rprototype to the to_binary function before the main function. -
#include <cassert> // Provides assert
-
#include <cstdlib> // Provides EXIT_SUCCESS
-
#include <iostream.h> // Provides cin, cout
-
#include "useful.h" // From Appendix H. Provides random_real, display
-
//using namespace std;
-
void to_binary(int number);
-
// PROTOTYPE for the function used in this demonstration program.
-
void random_fractal
-
(double left_height, double right_height, double width, double epsilon);
-
// Precondition: width and epsilon are both positive.
-
// Postcondition: The function has generated a random fractal from a line
-
// segment. The parameters left_height and right_height are the heights of the
-
// two endpoints of the line segment, and the parameter width is the segment's
-
// width. The generation of the random fractal stops when the width of the
-
// line segments reaches epsilon or less.
-
// Method of displaying the output: The height of the right endpoint of
-
// each line segment in the random fractal is displayed by calling the
-
// function display(...).
-
-
int main( )
-
{
-
cout << "The decimal number 10 equals ";
-
to_binary( 10 );
-
cout << " binary." << endl;
-
-
cout << "The decimal number 100 equals ";
-
to_binary( 100 );
-
cout << " binary." << endl;
-
-
cout << "The decimal number 1000 equals ";
-
to_binary( 1000 );
-
cout << " binary." << endl;
-
-
cout << "The decimal number 10000 equals ";
-
to_binary( 10000 );
-
cout << " binary." << endl;
-
-
return EXIT_SUCCESS;
-
}
-
-
void to_binary(int number)
-
{
-
if( number == 10)
-
return;
-
-
to_binary( number / 2);
-
-
cout << number % 2;
-
}
-
That will solve the issue.
Thanks
Raghuram
Thank you that worked...earlier i had void to_binary(int) as my prototype
...should had written it like you have it...Thanks a lot!!
Hi,
You have to add the rprototype to the to_binary function before the main function. -
#include <cassert> // Provides assert
-
#include <cstdlib> // Provides EXIT_SUCCESS
-
#include <iostream.h> // Provides cin, cout
-
#include "useful.h" // From Appendix H. Provides random_real, display
-
//using namespace std;
-
void to_binary(int number);
-
// PROTOTYPE for the function used in this demonstration program.
-
void random_fractal
-
(double left_height, double right_height, double width, double epsilon);
-
// Precondition: width and epsilon are both positive.
-
// Postcondition: The function has generated a random fractal from a line
-
// segment. The parameters left_height and right_height are the heights of the
-
// two endpoints of the line segment, and the parameter width is the segment's
-
// width. The generation of the random fractal stops when the width of the
-
// line segments reaches epsilon or less.
-
// Method of displaying the output: The height of the right endpoint of
-
// each line segment in the random fractal is displayed by calling the
-
// function display(...).
-
-
int main( )
-
{
-
cout << "The decimal number 10 equals ";
-
to_binary( 10 );
-
cout << " binary." << endl;
-
-
cout << "The decimal number 100 equals ";
-
to_binary( 100 );
-
cout << " binary." << endl;
-
-
cout << "The decimal number 1000 equals ";
-
to_binary( 1000 );
-
cout << " binary." << endl;
-
-
cout << "The decimal number 10000 equals ";
-
to_binary( 10000 );
-
cout << " binary." << endl;
-
-
return EXIT_SUCCESS;
-
}
-
-
void to_binary(int number)
-
{
-
if( number == 10)
-
return;
-
-
to_binary( number / 2);
-
-
cout << number % 2;
-
}
-
That will solve the issue.
Thanks
Raghuram
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Batista, Facundo |
last post by:
Here I send it.
Suggestions and all kinds of recomendations are more than welcomed.
If it all goes ok, it'll be a PEP when I finish writing/modifying the code.
Thank you.
.. Facundo
|
by: John Bentley |
last post by:
John Bentley:
INTRO
The phrase "decimal number" within a programming context is ambiguous. It could
refer to the decimal datatype or the related but separate concept of a generic
decimal number....
|
by: Mariusz Sakowski |
last post by:
I'm writing class which will be able to store large numbers (my
ambition is to make it able to operand on thousands of bits) and
perform various operations on it (similiar to those available with...
|
by: TK |
last post by:
I'm used to programming in c or c++ in which my problem is simple.
I want to be able to enter a value on a page (like 3.2), and then read
it as a 32-bit float and break it into it's individual...
|
by: No Such Luck |
last post by:
Hi all:
I have an unsigned char array (size 4):
unsigned char array;
array = 0x00;
array = 0x00;
array = 0x02;
array = 0xe7;
|
by: jaks.maths |
last post by:
How to convert negative integer to hexadecimal or octal number?
Ex: -568
What is the equivalent hexadecimal and octal number??
|
by: FAQ server |
last post by:
-----------------------------------------------------------------------
FAQ Topic - How do I convert a Number into a String with
exactly 2 decimal places?...
|
by: Terry Reedy |
last post by:
A. Joseph wrote:
These are number representation systems that can be applied to or used
with integral, rational (numberator,denominator), and 'point' numbers.
Try Wikipedia or any search...
|
by: Frinavale |
last post by:
Convert a Hex number into a decimal number and a decimal number to Hex number
This is a very simple script that converts decimal numbers into hex values and hex values into decimal numbers. The...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |