Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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 9-Apr-13 3:38am
Comments
Matthew Faithfull at 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?
ThePhantomUpvoter at 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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

You probably meant to say:
 
       cout << "Xc = " << Xc;
 
didn't you Smile | :)
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

#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;
}
  Permalink  
v2

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



Advertise | Privacy | Mobile
Web01 | 2.8.140709.1 | Last Updated 9 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid