Kirchoff Law in C++ Program
Kirchoff Law in C++ Program
1.0 INTRODUCTION
Nowadays C++ is useful and C++ is one of the most popular programming languages and is implemented on a wide variety of hardware and operating system platforms. C++ is an excellent language to start programming in a lot of applications that you use are probably written in c++ and once you learn some basic concepts, learning other languages, like java for example, will be much easier.
A computer program is a set of instructions that a programmer writes to tell a computer how to carry out a certain task. The instructions, however, must be in a language that the computer understands. Computers only understand binary language wish that composed of 1s and 0s. This is a low level language and very hard to program in. So humans invented higher level languages such as C++ or Pascal to make the job easier. As you will see, these languages are nearly like English but you dont have the freedom to write what you like there are still rules you have to follow. To convert a program in C++ to a binary or executable file that the computer can understand we use a compiler.
In this Project of BEC10102, all student electrical engineering should be involved themselves to design and developed using C++ program to completed the task or project are given by lecturer. My groups members able to solve the problem crating with the all knowledge what we learn, with used selection, if selection, if-else selection, and for looping in repetition structure, also function prototype, and function call.
1|Page
ITEM
DESCRIPTION
a = Option for the circuit type to calculate the total of resistance. The option as below: 1. Series 2. Parallel 3. Enter value of current & voltage. n = The number of the resistance that been entered. array[i] = Declaration for every value of resistance been entered. x = Option for user to choose 1=yes or 0=no to continue with current divider or voltage divider. V = The value of voltage that been entered.
INPUT DATA
I = The value of current that been entered. b = Option for the circuit type to calculate voltage divider or current divider. The option as below: 1. Series 2. Parallel. R = The total of resistance that been entered (RT). Ri = The value of resistance that been entered (Rn). Option = Option for the calculation type. The option as below: 1. Voltage 2. Current 3. Resistance 4. Power 5. Current Divider and Voltage Divider Calculation for the Voltage (option=1) V=I*R Calculation for the Current (option=2) I=V/R Calculation for the Total of Resistance (option=3) When a = 1 (series), the process is as below : resistance = resistance + array[i]
PROCESS
When a = 2 (parallel), the process is as below : denominator = denominator + 1/ array[i], resistance = 1 / denominator When a = 2 (parallel), the process is as below : R=V/I
2|Page
PROGRAM OUTPUT
3|Page
Y Option = 1 = N Y Option = 2
EnterI and R
V = I*R
PrintV
Enter V and R
I = V/R
Print i
N Option = 3
Y Rtotal
N Option = 4
Enter I and V
P = I*V
Print P
N Y Option = 1 V I divider
N END
4|Page
Rtotal
i ++
Enter a
aa
Y
R=V/I
Print R
N x=1
bb
Return Enter v Y
i=1
Array [i]
5|Page
From aa
Denominator=denominator+ (1/array[i])
Enter n
i<=n
Print resistance
Array[i]
i =1
Enter x
From bb
x=1
6|Page
V I divider
ENTER b
Print Ii
Vi = (Ri/R) * V
Print Vi
Return
7|Page
8|Page
9|Page
10 | P a g e
11 | P a g e
12 | P a g e
2. When user key in 1 is to calculate the voltage of resistor Current =40A Resistor = 8 ohm Voltage =40x8 =320V
13 | P a g e
4. Next press 3, to calculate the resistance, having two choice which it circuit are connect in parallel or series.
14 | P a g e
Figure 9 : End of Resistance Calculation (series) .Press 1 is continue voltage divider, shown as below R1=(10*20v)/20 = 10v R2=(10*20v)/20 = 10v
15 | P a g e
7. Next press 4 in the program able to calculate the power on the circuit. Power = cunrrent x voltage = 20x5 = 100w
16 | P a g e
Select 1 in series condition on the circuit . Voltage divider = 50x33 /66 = 25v
17 | P a g e
Figure 16 : Exit
18 | P a g e
Header need to define what needed in the program Void declare Rtotal for voiding return
Declare each of the integer and double variables use in this program
After user will select what user want to calculate either circuit in the series or parallel, if the user select 2 this program will execute for parallel circuit calculation.
Then program will go to selection function that been made by using else, else if and if function for series circuit calculation, selection need to use in this program to select the process in the program build in. Selection function help the program to detect what the process will be execute for these case the user choose parallel circuit calculation in the one parallel circuit. The program will show the user to Enter number of resistors in the circuit: then the user decide the how many resistor that user need to calculate in these parallel circuit. If the user insert 2 resistor need to be calculate the process execute to calculate the resistor, here the function for is use for repetition in the calculation show that if input inserted is 2 the function will repeat until it fulfill requirement, after the requirement have been fulfill it will stop inserting the resistor value.
19 | P a g e
The user select no 1 for calculate series resistance Input for resistance
If the user want to continue to calculate current divider user need to select 1 to continue to the next process. In the process user will show Please enter the value of current: and decide value of current in the circuit. When the user select for no 3 it calculate the resistance (R) in circuit when the user insert the value for input V and I.
Input V and I V= voltage I=current
Repetition Function
When the user select no 1 it calculate the voltage divider for series circuit.
User select 1 to calculate series voltage divider Formula to calculate voltage divider in circuit
21 | P a g e
default: other than input inserted the program will return to zero or program will ended To terminate the program and create new program to run
These is formula to calculate the resistance in the parallel circuit n=number of the resistor inside of the circuit and 1 is over 1/R1+1/R21/Rn, so these program use array to keep or hold the value of resistor.
22 | P a g e
23 | P a g e