Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
1.60/5 (5 votes)
See more:
C#
#include <iostream>
using namespace std;


int main(void)
{

    double f;
    double C;
    double L;
    double pi;
    double Xl;
    double Xc;


        cout<<"enter value of frequency";
        cin>>f;
        cout<<"enter value of L";
        cin>>L;
        cout<<"enter value of C";
        cin>>C;


    pi=3.14;
    Xl=2*(pi*f*L);
    Xc=1/(2*pi*f*C);

        cout<<"Xc";

        system("pause");

    return 0;
    }
Posted
Comments
Matthew Faithfull 9-Apr-13 9:48am    
What makes you think there are errors?
Does it compile?
Does it run?
Does it produce a result?
Is the result correct?
Why are you using such an inacurrate value for pi?
Why are you bothering to calculate Xl and then not using it?
[no name] 9-Apr-13 10:10am    
What do you mean it does not show any result? You calculate the value of Xl then throw the result away. You calculate the value of Xc then throw the value away. Then you output "Xc" just like you programmed it to.

You probably meant to say:

C++
cout << "Xc = " << Xc;


didn't you :-)
 
Share this answer
 
C++
#include <iostream>
using namespace std;
int main(void)
{
 
    double f=0.0;
    double C=0.0;
    double L=0.0;
    double p=0.0;
    double X=0.0;
    double Xc=0.0;
    double  pi=3.14;
  
    cout<<"enter value of frequency"<<endl;
    cin>>f;
    cout<<"enter value of L"<<endl;
    cin>>L;
    cout<<"enter value of C"<<endl;
    cin>>C;
 
    X=2*(pi*f*L);
    Xc=1/(2*pi*f*C);
 
    cout<<"Final Expected Result:"<<Xc;
 
    return 0;
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900