Need help creating a c++ program

C++ program to calculate the total impedance

Page 1 of 1

5 Replies - 4256 Views - Last Post: 02 October 2006 - 09:59 PM Rate Topic: -----

#1 kha77  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 27-September 06

Need help creating a c++ program

Post icon  Posted 27 September 2006 - 10:26 PM

hi
i need help to make a program in C++ using Microsoft visual studio.net 2003.
here is the question text

"The program is used to calculate the total impedance of an electrical circuit, which consists of a resistor, an inductor and a capacitor for a given frequency. Also the program should solve for voltages and current through the circuit with AC source.
First the program should ask the user to input the necessary data.
Then the program calculates both the reactive and inductive reactance and the total impedance of the circuit.
The program should inform the user if the voltage will lead or lag the current.
Also the program should check if the given frequency is the reasonance frequency.
Finally, the program displays the results."

it looks tough, huh!

Can any one write such program code, and post it on this topic, please!!.

by the way, the circuit is in series.

by the way it should be as a win32 project , and console application format, the code should be written in c++ file(.cpp)

i really would aprechiate the help

This post has been edited by kha77: 27 September 2006 - 10:33 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Need help creating a c++ program

#2 rahulbatra  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 16
  • View blog
  • Posts: 183
  • Joined: 28-December 05

Re: Need help creating a c++ program

Posted 27 September 2006 - 11:12 PM

Though I'm not a mod or the right person to be telling you this, but kindly read the rules of the forums. You *must* show some effort, and further on everybody here will help. In order to do that, please post the code you've already built, no matter if it has bugs or not.
Was This Post Helpful? 0
  • +
  • -

#3 DeeViLiSh  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 6
  • View blog
  • Posts: 175
  • Joined: 25-July 06

Re: Need help creating a c++ program

Posted 27 September 2006 - 11:13 PM

He is right

Quote

Post the code you have so far using the [code] tags. We can't help you if you don't post your code. We will not do your homework for you. You MUST show some effort.

Was This Post Helpful? 0
  • +
  • -

#4 kha77  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 27-September 06

Re: Need help creating a c++ program

Post icon  Posted 01 October 2006 - 11:29 PM

hi
sorry that i didnt include the code i wrote :P
here it is :music:

#include <stdio.h>
#include <math.h>
#include <string.h>
#define pi 3.1415926535897932384626433832795 
main ( )
{
	float Z, XL, XC, L, R, C, V, I, F, W, VR, VL, VC, WR;
	
	printf ("This program is made to calculate the total impedance(Z)of an electrical circuit and the voltage and current through the circuit, by inputing the frequency (F), Source voltage (V), Resistance of the resistor ®, the capacitor capacitance ©and the value of the inductor (L)\n");

	printf ("Please enter the frequency (F)\n");
	scanf ("%f",&F);

	printf ("Please enter the source voltage (V) in volts\n");
	scanf ("%f",&V);

	printf ("Please enter the Resistance of the Resistor ® in ohms\n");
	scanf ("%f",&R);

	printf ("Please enter the Capacitance of the Capacitor © in Farad\n");
	scanf ("%f",&C);

	printf ("please enter the Value of the Inductor (L) in Henry\n");
	scanf ("%f",&L);
 
	W = 2*pi*F;
	XL = W*L;
	XC = 1/(W*C);
	Z = sqrt((R*R)+((XL-XC)*(XL-XC)));
	I = V/Z;
	VR = I*R;
	VL = XL*I;
	VC = XC*I;
	WR = 1/(sqrt(L*C));

		if(XL>XC)
			printf ("The current will lags( The voltage will lead)\n");
		else printf ("The current will leads (The voltage will lags)\n");


		if(WR = W)
			printf ("The given frequency is the resonance frequency\n");
		else printf ("The given frequency is not the resonance frequency\n");

		
printf ("Z = %f\n",Z);
printf ("I = %f A\n",I);
printf ("VR = %f V\n",VR);
printf ("VL = %f V\n",VL);
printf ("VC = %f V\n",VC);
}


so, what you think? B)

This post has been edited by Dark_Nexus: 02 October 2006 - 12:05 AM

Was This Post Helpful? 0
  • +
  • -

#5 frog  Icon User is offline

  • unleashed
  • member icon

Reputation: 2
  • View blog
  • Posts: 683
  • Joined: 26-March 06

Re: Need help creating a c++ program

Posted 01 October 2006 - 11:53 PM

just a little problem that i see in the calculations .

shudnt the resonant angular velocity be equal to 1/r times square root of inductance*capacitance .just check that condition for resonant frequency
Was This Post Helpful? 0
  • +
  • -

#6 kha77  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 27-September 06

Re: Need help creating a c++ program

Posted 02 October 2006 - 09:59 PM

im not sure about that!!
i will check it with my physics teacher
thanks any way
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1