100% found this document useful (1 vote)
164 views

C++ Circuit Project

This document describes a C++ programming project to calculate voltages in an electrical circuit. The program uses Cramer's rule to determine the voltages at two nodes given the circuit's current sources and resistances. The program structure uses objects and variables to represent the circuit components and calculates the determinant and node voltages. The output displays the calculated voltages which match the hand calculations, demonstrating that the program successfully solved the circuit problems.

Uploaded by

anezi8family
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
164 views

C++ Circuit Project

This document describes a C++ programming project to calculate voltages in an electrical circuit. The program uses Cramer's rule to determine the voltages at two nodes given the circuit's current sources and resistances. The program structure uses objects and variables to represent the circuit components and calculates the determinant and node voltages. The output displays the calculated voltages which match the hand calculations, demonstrating that the program successfully solved the circuit problems.

Uploaded by

anezi8family
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

TENNESSEE STATE UNIVERSITY

College of Engineering
Department of Electrical and Computer
Engineering
CIRCUITS-I
C++ PROJECT -1
Abdullah Alanezi
Dr. Marpaka
DUE DATE
04/15/2015

TABLE OF CONTENTS

Table of contents
I.

Problem Statement .

II.

Computer Program Description:..

III.

Computer Program Plan: ..

V.

Input data:... ...

VI.

Output

VII.

Conclusion.

VIII. reference .

I.

Problem Statement:
Use C++ to determine problem 3.19, 3.24 and 3.25

II.

Computer Program Description:

a. Overview:
The purpose of this project was to use a computer program called C++ so that it
will determine the voltage and the current with a C++ language (coding).
b. Assumptions:
N/A
c. Variable List:
N/A
d. Limitations
There is one point where C++ won't help you, but you'll have to use your
compiler's implementation to integrate with assembly code. Basically, the only
limitation is what would make your code non-portable to other platforms, namely
writing assembly statements.
The second limitation is that code compiled for a certain architecture will be hard
to be used on other platforms... but if we think about the processor as a virtual
machine... we might even disconsider lack of bytecode as a shortcoming.
III.

Computer Program Plan:


a. Structure:
In general, structures are usually useful when a lot of data is needed to be grouped
together; for example, they can be used to hold any records from an organized
collection of data or to store any information in an address book. Structures are a

way of storing different values in variables of potentially different types under the
same name.
Making it a modular program, its way too easy to modify it because of its design.

b. Algorithm:
N/A
c. Flow Chart:
N/A
IV.

Computer Program Listing:


N/A

V.

Input data:

VI.

output

Thisprogramcalcultedthenodevoltagesofacircuithaveforenon //
referencenodes\n
withtwoindependentcurrentsourcesandoneindependentvoltage //
.source
<include<iostream#
<include<cmath#
<include<iomanip#

;usingnamespacestd

()intmain
}
.Declareandinitailizetheobjects//
;doubledomain,domainV1,domainV2,V1,V2

cout<<"NOTETHATResistorsR1,R2,andcurrentsourceI1
;connectedtonode1."<<endl

cout<<"ResistorsR2,R3,andcurrentsourceI2connectedtonode
;2.\n"<<endl

.Calculatethedomainofthemetrix//

;domain=(8*13)((7)*(2))

;domainV1=36*(13)((2)*(504))

;domainV2=8*(504)(36*(7))

;cout<<"Deltais\nD="<<domain<<endl
;cout<<"Delta1is\nD1="<<domainV1<<endl
;cout<<"Delta2is\nD2="<<domainV2<<endl

if(domain!=0)
}
.Calculatethenodevoltageofthecircuit //
;V1=domainV1/domain
;V2=domainV2/domain

;cout<<"Thevoltageatnode1is\nV1="<<V1<<endl
;cout<<"Thevoltageatnode2is\nV2="<<V2<<endl

{
else
}
cout<<"TheDeterminantiszero\nD=0\nCramer'srulecannot
;usedforthiscircuit."<<endl

{
;return0

Conclusion:
In conclusion, this program helped to understand how currents and voltages are
worked together in the C++ form. Moreover, learning about structures and how it
works by values in variables and storage. The program result was matched as hand
calculation. I really enjoyed this program and as a future it will always help for my other
classes.

Reference:
Alexander, Charles K. and Matthew Sadiku, Fundamentals of Electric
Circuits, 5th Edition, McGraw Hill, Boston, MA, 2013.
PSPICE. Upenn.edu. University of Pennsylvania. n.d. Web. 5 Dec. 2012.

You might also like