![]() |
Call to a Function more than once
I have a program to write as part of assignment for class, using C++ of course and using functions. Basically I have to write a Resistor Colour Code Calculator which will allow a user to input the colours and it would give them a value as well as a tolerance range. I am currently having trouble writing the part for the first two bands which are the significant figures. Form what I can see I need to call the Significant Figures function twice, and I have no idea how to do it.
int sigfig () //Significant Figures Functionint main() // Main Function |
Re: Call to a Function more than once
Your question isn't clear. Functions are designed to be called repeatedly. Otherwise, you might as well use inline code and booger up your footprint.
Please, henceforth, put your code in code tags. Because of the ugligness and unformatted nature of the code, I won't even read it. Consequently, I cannot give you a meaningful comment, other than the above. |
Re: Call to a Function more than once
All I did was use the wrong code tags, didn't realise that there were more than one of them. I have solved the problem without the use of functions but the teacher wants it done with functions.
What i meant is that I want to call the function twice, for both band 1 and band 2. And having it being able to read the colour and give me the number for both those bands. Note the following code is not the full code but just parts of it. :
|
Re: Call to a Function more than once
:
void myFunction()myFunction() is called twice in this example. |
Re: Call to a Function more than once
Okay wizard, now after that call to that function is made twice I need to store two different variables, using that same function.
But thanks for your help, that seems like with will help me out a lot. I'll stop by if I have any more problems. |
Re: Call to a Function more than once
Well in the example I gave you the function returns void which is nothing. You might want to return an integer, int.
:
int add(int a, int b)This code would simply add a and b and return it. I hope this helps a bit more |
Re: Call to a Function more than once
Quote:
:
int myFunction() |
Re: Call to a Function more than once
Quote:
|
Re: Call to a Function more than once
Sorry, next time I'll write the OP's code for them... :icon_confused:
|
Re: Call to a Function more than once
Quote:
|
| All times are GMT -5. The time now is 3:29 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC