resistor

Hi, I got a program here and it is not making the calculations,I've tried different solutions but they are not working for me, any suggestions??



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <iostream>
#include <cmath>
#include <iterator>     // std::advance
#include <cstdlib>

#define VBE 0.7f

using namespace std;
/****************************************************************************/
float Calcib(float ic, float beta);

float Calcrb(float Vcc, float ib); 

float Calcrc(float Vcc, float ic);

/****************************************************************************/
int main(int argc, char** argv) {
    
    float ib;
    float rc;
    float rb;
    float Vcc = 0.0;
    float ic = 0.0; 
    float beta = 0.0;


    ib = Calcib (ic, beta);
    rb = Calcrb (Vcc, ib);
    rc = Calcrc (Vcc, ic);
    
    
    cout << "Please enter the value for Vcc: " ;  //prints sentence on screen 
    cin >> Vcc;                                  //value entry
    
    cout << "Please enter the value for ic: " ;  //prints sentence on screen
    cin >> ic;                                  //value entry
    
    cout << "Please enter a value for beta; " ;  //prints sentence on screen
    cin >> beta;
    
    
    cout<< "*.*.*.*.*.Base Bias.*.*.*.*.*" << endl;
    cout<< "vcc\t\t "<< Vcc << endl;
    cout<< "ic \t\t " << ic << endl;
    cout<< "beta\t\t "<< beta << endl;
    cout<< "ib\t\t " << ib << endl;
    cout<< "rb\t\t " << rb << endl;
    cout<< "rc\t\t " << rc << endl;
    cout<< "*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*" << endl;
        
    return 0;
}
    
    float Calcib(float ic, float beta, float ib)
    {
        ib = ic / beta;
        
        return ib;
    }
    
    float Calcrb(float Vcc, float ib, float rb)
    {
        rb = ceil((Vcc - VBE) / ib);
        
        return rb;
    }
    
    float Calcrc(float Vcc, float ic, float rc)
    {  
        rc = ceil((0.5 * Vcc) / ic);
        
        return rc;
    }

Last edited on
For one thing, your function prototypes don't agree with your function definitions.
Your function prototypes take two arguments.
Your function definitions take three arguments.
You should have received linker errors.

PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
for another thing, you do be using the functions before you enter the values for their parameters. Your answers are going to be pure gibberish.
so I changed it to this, but still, I am not getting the right math done, the calculations I mean. And thanks for the hints

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
[code]
#include <iostream>
#include <cmath>
#include <iterator>     // std::advance
#include <cstdlib>

#define VBE 0.7f

using namespace std;
/****************************************************************************/
float Calcib(float ic, float beta, float ib);

float Calcrb(float Vcc, float ib, float rb); 

float Calcrc(float Vcc, float ic, float rc);

/****************************************************************************/
int main(int argc, char** argv) {
    
    float ib;
    float rc;
    float rb;
    
    float Vcc;
    float ic; 
    float beta;

    ib = Calcib(ic, beta, ib);
    rb = Calcrb(Vcc, ib, rb);
    rc = Calcrc(Vcc, ic, rc);
    
    
    cout << "Please enter the value for Vcc: " ;  //prints sentence on screen 
    cin >> Vcc;                                  //value entry
    
    cout << "Please enter the value for ic: " ;  //prints sentence on screen
    cin >> ic;                                  //value entry
    
    cout << "Please enter a value for beta; " ;  //prints sentence on screen
    cin >> beta;
    
    
    cout<< "*.*.*.*.*.Base Bias.*.*.*.*.*" << endl;
    cout<< "vcc\t\t "<< Vcc << endl;
    cout<< "ic \t\t " << ic << endl;
    cout<< "beta\t\t "<< beta << endl;
    cout<< "ib\t\t " << ib << endl;
    cout<< "rb\t\t " << rb << endl;
    cout<< "rc\t\t " << rc << endl;
    cout<< "*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*" << endl;
        
    return 0;
}
    
    float Calcib(float ic, float beta, float ib)
    {
        ib = (ic / beta);
        
        return ib;
    }
    
    float Calcrb(float Vcc, float ib, float rb)
    {
        rb = ceil((Vcc - VBE) / ib);
        
        return rb;
    }
    
    float Calcrc(float Vcc, float ic, float rc)
    {  
        rc = ceil((0.5 * Vcc) / ic);
        
        return rc;
    }
[/code]
Last edited on
Line 25: ic is an uninitialized variable.

Line 28: What value of ic do you think you're passing to the function?

Ditto for beta and Vcc.
your program, in wordz:
declare a bunch of floats to random values.
*) call your computations with random values from above.
read the variables from the user
print the results of * above


Last edited on
Topic archived. No new replies allowed.