i had compile this program and it succeeded but can't debug

May 26, 2012 at 00:44:51
Specs: Windows 7
#include <iostream>
#include <cmath>


using namespace std;

double selection();
double inductionVoltage();
double reluctanceValue(double Wb);
double magnetomotiveForce(double At);
double flux();
double answers;
double displayAnswer ();

int main ()
{
selection();
int choice;
cout<<"Do you want to continue?"<<endl;
cout<<"1.YES"<<endl;
cout<<"2.NO"<<endl;
if(choice==1)
{
cout<<selection()<<endl;
}
if(choice==2)
{
cout<<displayAnswer()<<endl;
}
else
{
cout<<"Thank You"<<endl;
}
}
double selection()
{
int Wb;
int At;
int choice;
cout<<" "<<"ELECTROMAGNETIC CALCULATOR"<<endl;
cout<<endl;
cout<<" "<<"1. INDUCTION VOLTAGE"<<endl;
cout<<" "<<"2. RELUCTANCE"<<endl;
cout<<" "<<"3. MAGNETOMOTIVE FORCE"<<endl;
cout<<" "<<"4. FLUX"<<endl;
cout<<" "<<"5. Quit"<<endl;
cout<<endl;
cout<<"Enter your choice (1-5) : ";
cin>>choice;
cout<<endl;


switch (choice)
{
case 1: inductionVoltage();
cout<<endl;
displayAnswer ();
break;

case 2: reluctanceValue(Wb);
cout<<endl;
displayAnswer ();
break;

case 3: magnetomotiveForce(At);
cout<<endl;
displayAnswer ();
break;

case 4: flux();
cout<<endl;
displayAnswer ();
break;


case 5:cout<<endl;
cout<<"Bye!"<<endl;
break;

default :cout<<"You may enter only 1, 2, 3, 4 or 5."<<endl;
}

return 0;


}

double inductionVoltage()
{
double fluxDensity;
double length;
double velocity;
double answers;

int f;
const int r=1;
cout<<"please enter your number of data set you want to calculate"<<endl;
cin>>f;
const int c=3;
int aryData[r][c];
for(int c = 0; c < 3; c++)
{
cout << "Enter the flux density : ";
cin >> fluxDensity;
cout<<"Enter the lenght of conductor:";
cin>>length;
cout<<"Enter the velocity of motion:";
cin>>velocity;
for (int r=0;r<=f;r++)
cin >> aryData[r][c];
cout<<endl;
}
cout<<"Your Data Are : "<<endl;
for ( int r = 0; r <=f; r++)
{
for(int c = 0; c < 3; c++)
cout <<" "<< aryData[r][c] ;
cout << endl;
}

answers= fluxDensity*length*velocity;

cout <<" FLUX DENSITY | LENGTH | VELOCITY |INDUCTION VOLTAGE "<<endl;
cout <<"----------------------------------------------------------------------------------------"<<endl;

cout<<"Your Data Are : ";

for ( int r = 0; r <=f; r++)
{

int c;
c=0;

while( c < 3)
cout <<" |"<< aryData[r][0]<<" |"<<aryData[r][1] <<" |"<<aryData[r][2]<<" |"<<answers;
cout << endl;
c++;
}


cout <<"----------------------------------------------------------------------------------------"<<endl;


return answers;
}


double reluctanceValue()
{
double length;
double area;
double permeability;
int f;
const int r=1;
cout<<"please enter your number of data set you want to calculate"<<endl;
cin>>f;
const int c=3;
int aryData[r][c];
for(int c = 0; c < 3; c++)
{
cout << "Enter the length of magnetic path : ";
cin >> length;
cout<<"Enter the cross sectional area :";
cin>>area;
cout<<"Enter the permeability:";
cin>>permeability;
for (int r=0;r<=f;r++)
cin >> aryData[r][c];
cout<<endl;
}
cout<<"Your Data Are : "<<endl;
for ( int r = 0; r <=f; r++)
{
for(int c = 0; c < 3; c++)
cout <<" "<< aryData[r][c] ;
cout << endl;
}
return 0;

answers= length/(permeability*area);


cout <<" LENGTH | PERMEABILITY | AREA |RELUCTANCE "<<endl;
cout <<"----------------------------------------------------------------------------------------"<<endl;

cout<<"Your Data Are : ";

for ( int r = 0; r <=f; r++)
{

int c;
c=0;

while( c < 3)
cout <<" |"<< aryData[r][0]<<" |"<<aryData[r][1] <<" |"<<aryData[r][2]<<" |"<<answers;
cout << endl;
c++;
}


cout <<"----------------------------------------------------------------------------------------"<<endl;

return answers;
}
double magnetomotiveForce()
{
double turns;
double current;
int f;
const int r=1;
cout<<"please enter your number of data set you want to calculate"<<endl;
cin>>f;
const int c=2;
int aryData[r][c];
for(int c = 0; c < 2; c++)
{
cout << "Enter the number of wire turns : ";
cin >> turns;
cout<<"Enter current flow :";
cin>>current;

for (int r=0;r<=f;r++)
cin >> aryData[r][c];
cout<<endl;
}
cout<<"Your Data Are : "<<endl;
for ( int r = 0; r <=f; r++)
{
for(int c = 0; c < 2; c++)
cout <<" "<< aryData[r][c] ;
cout << endl;
}
return 0;

answers= turns*current;
cout <<" TURNS | CURRENT |INDUCTION VOLTAGE "<<endl;
cout <<"----------------------------------------------------------------------------------------"<<endl;

cout<<"Your Data Are : ";

for ( int r = 0; r <=f; r++)
{

int c;
c=0;

while( c < 3)
cout <<" |"<< aryData[r][0]<<" |"<<aryData[r][1] <<" |"<<answers;
cout << endl;
c++;
}


cout <<"----------------------------------------------------------------------------------------"<<endl;

return answers;
}

double flux(double reluctanceValue,double magnetomotiveForce)
{

answers= magnetomotiveForce/reluctanceValue;
cout<<"your magnetomotive force is:"<<magnetomotiveForce<<"your reluctance is:"<<reluctanceValue;

return answers;
}
double displayAnswer ()

{
if(answers>0)
{
cout<<"The Results is: "<<answers<<endl;
}
else;

return 0;
}


See More: i had compile this program and it succeeded but cant debug

Report •

#1
May 26, 2012 at 02:28:56
So, why can't you debug it. What happens when you try?

Rather than posting reams of source code it would be more helpful to tell us which compiler and/or IDE you are using, what command you are using to debug, and what error message you get when you try.


Report •

#2
May 26, 2012 at 09:44:14
which ide do u use in compiling the code

Report •

#3
June 20, 2012 at 08:03:50

from our firiends at codepad
cc1plus: warnings being treated as errors
In function 'double selection()':
Line 55: warning: 'Wb' is used uninitialized in this function
Line 59: warning: 'At' is used uninitialized in this function

:: mike


Report •
Related Solutions


Ask Question