Originally Posted by
phoenixg
Thanks for that, everyone. I looked at it hundred times and didn't see the r1 and
r2.
I only gave the output a int value because that is what the design said to do. I also thought that since i had given it a float value that it should stay that way.
I still can't get it to compile though. It refers to an 'expected expression before )', in the error message when I compile it, but i still haven't worked out how to use the error messages to locate the problem.
Regards, phoenixg
Code:
#include <stdio.h> /*printf, scanf definitions*/
#include <math.h>
#define Vc 3.3
#define Ve 0.75 /* definition of the constants */
#define Vin 0.02
#define Hfe 95
int main(void)
{
float Ic,Vcc; /*declared variables*/
float R1, R2, R3, R4;
float Ib, Vb, Ks, Vout;
V---- Missing comment prefix
printf("Enter the value of Ic:"); /* prompts for the variables from the user*/
scanf("%f", &Ic); /*inputs the variable as a float*/
printf("Enter the value of Vcc:");
scanf("%f", &Vcc);
printf("===================");
Ib = Ic / Hfe; /*calculates the base current*/
R1 = (Vcc - Vc) / Ic; /*calculates the value of R1*/
R2 = Ve / (Ic + Ib); /*calculates the value of R2*/
Vb = Ve + 0.7; /*calculates the value of Vb*/
R4 = Vb / (5 * Ib); /*calculates the value of R4*/
R3 = (Vcc - Vb) / (6 * Ib); /*calculates the value of R3*/
Ks = r1 / r2; /*calculates the signal amplification*/
Vout = Vin * Ks; /*calculates the output signal*/
printf("Resistors:\n");
printf("R1 = %10d ohm\n", R1);
printf("R2 = %10d ohm\n", R2);
printf("R3 = %10d ohm\n", R3);
printf("R4 = %10d ohm\n\n", R4);
printf("Output voltage:\n",);
printf("Vout = %10.2f v \n", Vout);
printf("====================");
return (0);
}