LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-17-2012, 10:21 AM   #1
user9697
LQ Newbie
 
Registered: Oct 2012
Posts: 28

Rep: Reputation: Disabled
Another compiling question


learning C++ , started in win on Dev cpp, and lost my comp for a while (tech difficalties ) got rid of the dual boot and now am on 12.04 lts, never compiled in linux and its frustrating hehe, i tried both c++ and g++

before i stoped i had made a small converting (non gui) app and it ran grt before (in a terminal) but .... well its going something like this

:~/cp$ c++ main.cpp -o main
main.cpp: In function ‘int main()’:
main.cpp:143:17: error: ‘system’ was not declared in this scope
main.cpp: At global scope:
main.cpp:308:1: error: ‘endl’ does not name a type

am lost on both errors *** i din't even know endl had types

this is the code
Code:
# include <iostream>
using namespace std;
int temps();
int heavy();
int main ()
{
float a;
char b;
float c;
float d;
float e;
float f;
float g;
float h;
float i;
float j;
float k;
float l; 
int u =1;
int n;
cout << "################################################################################"<< endl
<<">WELCOME TO THE C,M.D CONVERTING TOOL >>>>><<<<<<<>>>>>>>><<<<<<>>>><<<<>>><<<>>>><<<<<<>>>><<<<<<<>>>>><<<<<>>>><<<<<>>><<<>>>>><<<<<>>>><<<>>><<<>>><<><<<>>><"<< endl
<<"--------------------------------------------------------------------------------" <<
 endl << "ENTER 1 TO USE THE DIST CONVERTER >><< ENTER 2 TO USE THE TEMP CONVERTER" << endl <<"ENTER 3 TO USE WEIGHT CONVERTER, ENTER ANY OTHER # TO EXIT" << 
 endl <<"********************************************************************************" 
 << endl 
 <<"********************************************************************************" << endl
 <<"********************************************************************************" << endl
 <<" *******      ******     ** **   ***     ***   **     **" << endl
 <<"*********   **********   ** **  ***     ** **  ****   **"     << endl
 <<"***   *********   ****   ** **  **  **  *****  ** **  **"      << endl
 <<"***     ******    ****   ** **  ******  *****  **  ** **"       << endl
 <<"***      ****     ****   *****   ****   ** **  **   ****"       << endl
 <<"--------------------------------------------------------------------------------" << endl
 <<"--------------------------------------------------------------------------------" << endl
 <<">CHOSE A CONVERTER<<<<<<<<<<<>>>>>>>>>>>><<<<<<<<<<>>>>>>><<<<>>><<<>>>><<<<<>><" << endl;
cin >> (n);
if (n <= 3 && n >=1)
{
      if ( n == 3)
      heavy();
 else if (n==2)
  temps();    
   if (n == 1)
     
while (u == 1)
{
cout << "---------------------------------------" <<       
endl << "WELCOME TO THE C.M.D DIST CONVERTER"  <<
endl << "***************************************" <<
endl << "* miles to km.> k" <<
endl << "*km to miles >> m" <<
endl << "*yard to metre> M        ********************************************************" <<
endl << "* metre to yard>y        **  *     *     *    *     *     *     *     *     *  **" <<
endl << "*foot to metre> t        **  *     *     *    *     *     *     *     *     *  **" <<
endl << "*metre to foot> T        ********************************************************" << 
endl <<"*foot to cm    > f     " <<
endl <<"*cm to foot    > c" <<
endl <<"* inch to cm   > i      " <<
endl <<"*cm to inch>c  > n" <<
endl << "-----------------"<< 
endl <<"ENTER FUNCTION KEY " <<
endl <<"-------------------" <<
endl;

cin >>(b);
cout <<" ENTER THE DISTANCE" << endl
 << "___________________ " << endl;
cin >> (a);

(c) = (a)*1.609;
(d) = (a)/.5936133;
(e) = (a)/1.09;
(f) = (a)*1.09;
(g) = (a)/0.3028;
(h) = (a)*30.48;
(i) = (a)*3.2808399;
(j) = (a)*0.0328084;
(k) = (a)*2.54;
(l) = (a)*0.3937008;

switch (b)

case 'k' :
     {
     cout << (c) << "    KM" << endl
      << "__________________________________" << endl;
     break;
     
case 'm' :
     cout << (d) << "   MILES" << endl <<
      "________________________________" << endl;
     break;  
     
case 'M' :
     cout << (e) << "   METRE" << endl <<
      "__________________________________" << endl;
     break;        
case 'y' :
     cout << (f) << "   YARD" << endl <<
      "____________________________________" << endl;
     break;     
case 't' :
     cout << (g) << "   METRE" << endl <<
      "___________________________________" << endl;
     break; 
     
case 'T' :     
     cout << (i) << "  FEET" << endl <<
      "____________________________________" << endl;
     break; 
case 'f' :
     cout << (h) << "  CM" << endl <<
      "______________________________________" << endl;
     break;    
case 'c' :      
  cout << (j) << "    FEET" << endl <<
   "______________________________________" << endl;
  break;       
case 'i' :
     cout << (k)  << "    CM" << endl << 
     "_____________________________________" << endl;
     break;
case 'n' :
     cout << (l)  << " INCH" << endl <<
      "______________________________________" << endl;
     break;            
     
default :
        cout << " WRONG KEY PLEASE TRY AGAIN !!!"<< endl;
        }
        cout << " ENTER 1 TO CONTINUE >>><<< ENTER ANY OTHER # TO GO TO MAIN MENU" << endl
         << "-------------------------" <<endl;
        cin >> (u);
}
 
  system("pause");
return main();

{

}
}
}
/* *********************************************************************************************** */
/* *********************************************************************************************** */

int temps()
{
float a;
char b;
float c;
float d;
float e;
float f;
int i = 1;
 const float g =1.8;
 while (i == 1)
 {
cout
<<"##############################################################################" << endl 
<<"WELCOME TO THE C.M.D TEMP CONVERTER " << endl
<<"******************************************************************************" << endl
<<"When prompted for unit                     *********      *********                 " << endl
<<"                                         *********        *******     " << endl
<<"Enter f to convert celcius to farenheit ****             **  **        " << endl 
<<"*************************************** ****            **  **          " << endl 
<<"Enter c to convert farenheit to celcius ****           **  ** ***********         " << endl
<<"**************************************** ********     **  **  **********          " << endl
<<"Enter temp                                 *******  **   **   ****           " << endl 
<<"----------                                         **    **   ********            " << endl
<<"                                                   **    **   ******** *******           "<< endl
<<"                                                    *****     ****    ***   *** " << endl
<<"                                                              ****   ***     *** " << endl
<<"                                                              ****    ***   *** " << endl
<<"                                                              ****      ***** " << endl;
cin >> (e);
cout << "ENTER UNIT" << endl <<"-----------";
cin >> b;
  c = (e)*(g)+32;
  d = (e)*.5555557-18;
 
switch (b)
{
case 'f' :
     
     cout << (c) << "   fahrenheit" << endl
      << "----------------------------------------------" << endl;
break;

case 'c' :
     cout << d << " celcius" << 
     endl << "-----------------------------------------------" << endl;

}     
cout <<"TO CONTINUE ENTER 1 >><<< TO go to MAIN MENU ENTER ANY OTHER NUMBER" <<
 endl <<"-----------------------------------------------------";
cin >> (i);
}
return main();
}
/* ************************************************************************************************************************************************************************** */
/* ************************************************************************************************************************************************************************** */

int heavy()
{
float a;
float b;
float c;
float d;
float e;
float f;
float g;
float h;
float i;
float j;
float l;
int q =1;

while (q == 1)
{
char k;
cout <<"############################################" << endl
<< "WELCOME TO THE C.M.D WEIGHT CONVERTER >>><<<" << endl
<<"********************" <<
endl <<"|pound to kilo-->k                ***      ****      ***                   " <<
endl <<"|kilo to pound-->p             **************************                     " <<
endl <<"|ounce to gram-->g               ***       **       ***       " <<
endl <<"|gram to ounce-->o                *        **        *    " <<
endl <<"|carat to gram-->G                *        **        *     " <<
endl <<"|gram to carat-->t             *******     **     *******                 " << 
endl <<"|stone to kilo-->K              *****      **      *****               " << 
endl <<"kilo to stone--->s                *****      **      *****             " <<
endl <<"pound to tone--->t               *****      **      *****               " <<
endl <<" tone to pound-->P                         **             " << endl 
     <<"*******************                     *********                          " <<
 endl <<"ENTER UNITS                           *************                       " <<
 endl <<"-------------------                 *****************"<< endl;
cin >> (k);
cout <<"*************************" << endl << "ENTER THE AMOUNT" << endl <<"-------------"<<endl;
cin >> (a);
(b) =(a)*0.4536;
(c) =(a)*2.2045855;
(d) =(a)*28.35;
(e) =(a)*0.0352734;
(f) =(a)*0.2;
(g) =(a)*5;
(h) =(a)*0.157473;
(i) =(a)*6.3502932;
(j) =(a)*0.0004;
(l) =(a)*2500;

 switch (k)
{ 
case 'k' :
      cout << (b) << "   KILOS" << endl
       <<"--------" << endl;
      break;
case 'p' :
      cout << (c) << "   pounds" << endl
       <<"---------" << endl;
      break;
case 'g' :
     cout << (d) << "   grams" << endl 
     << "--------" << endl;
     break;
case 'o' :
     cout <<(e) << "   ounces" << endl <<
      "---------" << endl;
     break;
case 'G':
     cout << (f) <<"   grams" << endl << 
     "---------" << endl;
     break;
case 'c' :
     cout << (g) <<"   carats" << endl <<
      "---------" << endl;
     break;

case 'K' :
     cout << (i) << "   kilos" << endl <<
     "---------" << endl;
     break;                           
case 's' :
     cout << (h) << "   stones" << endl <<
     "---------" << endl;
     break;
case 't' :
     cout << (j) << "   tones" << endl <<
      "--------" << endl;
     break;



}
cout << "ENTER 1 TO CONTINUE >><< ENTER ANY OTHER NUMBER TO RETURN TO MAIN MENU" << endl
 <<"**********************************************************************";
cin >> (q);     
}
return main();
}
endl
 
Old 10-17-2012, 10:27 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
ad 1: you forgot #include <cstdlib>
ad 2: I won't count your lines; please quote line#308 separately

PS: return main(): oh-no-no-no, use 'goto BEGIN' instead:

Code:
int main (void)
{
BEGIN:
/* tons of code */
goto BEGIN;
}
 
1 members found this post helpful.
Old 10-17-2012, 10:40 AM   #3
user9697
LQ Newbie
 
Registered: Oct 2012
Posts: 28

Original Poster
Rep: Reputation: Disabled
308, is the last line, after return ..
 
Old 10-17-2012, 10:43 AM   #4
user9697
LQ Newbie
 
Registered: Oct 2012
Posts: 28

Original Poster
Rep: Reputation: Disabled
Code:
#include <cstdlib>
# include <iostream>
using namespace std;
int temps();
int heavy();
int main ()
{ BEGIN:
float a;
Code:
MAIN MENU" << endl
 <<"**********************************************************************";
cin >> (q);     
}
goto BEGIN;
}
endl

Last edited by user9697; 10-17-2012 at 10:49 AM.
 
Old 10-17-2012, 10:48 AM   #5
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
Quote:
main.cpp:143:17: error: ‘system’ was not declared in this scope
Every function need to be declared, "system" is declared in "stdlib.h" just include this file. But it probably not work as excepted, because Windows and Linux has different shells command, and pause may not exists on your system.

Quote:
main.cpp:308:1: error: ‘endl’ does not name a type
And what it doing on the last line of your code?

Also you shouldn't invoke "return main()", because you probably created infinite loop with memory leak. If you want this behavior use "while(1)" or similar construct.
 
1 members found this post helpful.
Old 10-17-2012, 10:54 AM   #6
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Quote:
Code:
}
goto BEGIN;
}
endl
And what that endl is supposed to mean there?
 
1 members found this post helpful.
Old 10-17-2012, 11:02 AM   #7
user9697
LQ Newbie
 
Registered: Oct 2012
Posts: 28

Original Poster
Rep: Reputation: Disabled
well thx guys for your help, it let go of those errors,
but now like you said
Quote:
Every function need to be declared, "system" is declared in "stdlib.h" just include this file. But it probably not work as excepted, because Windows and Linux has different shells command, and pause may not exists on your system.
i got
:~/cp$ c++ main.cpp -o main
main.cpp: In function ‘int heavy()’:
main.cpp:307:6: error: label ‘BEGIN’ used but not defined

working on the functions .. guess i should just go over it all . any thing else you guys can see ???

and the last line 308 was endl
but i got rid
Code:
<<"**********************************************************************";
cin >> (q);     
}
goto BEGIN;
}
 
Old 10-17-2012, 11:06 AM   #8
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Quote:
Originally Posted by user9697 View Post
well thx guys for your help, it let go of those errors,
but now like you said
i got
:~/cp$ c++ main.cpp -o main
main.cpp: In function ‘int heavy()’:
main.cpp:307:6: error: label ‘BEGIN’ used but not defined

working on the functions .. guess i should just go over it all . any thing else you guys can see ???

and the last line 308 was endl
but i got rid
Code:
<<"**********************************************************************";
cin >> (q);     
}
goto BEGIN;
}
You probably forgot to define the label BEGIN: somewhere in your code.

IMHO, don't use "goto" in your code; it is considered bad practice. Use a while-loop, a for-loop, or a do-while-loop to achieve your goal.

Edit:

Code:
#include <iostream>

void bad_practice()
{
    int i = 0;

BEGIN:
    std::cout << "At the beginning..." << std::endl;
    if (++i < 5)
    {
        goto BEGIN;
    }
    std::cout << "At the end." << std::endl;
}

void good_practice()
{
    for (int i = 0; i < 5; ++i)
    {
        std::cout << "At the beginning..." << std::endl;
    }
    std::cout << "At the end." << std::endl;
}

int main()
{
    bad_practice();
    good_practice();
}

Last edited by dwhitney67; 10-17-2012 at 11:09 AM.
 
1 members found this post helpful.
Old 10-17-2012, 11:09 AM   #9
user9697
LQ Newbie
 
Registered: Oct 2012
Posts: 28

Original Poster
Rep: Reputation: Disabled
sorry guys you must be in newb hell here .. ok al make the loop ,

Quote:
You probably forgot to define the label BEGIN: somewhere in your code.
???

Last edited by user9697; 10-17-2012 at 11:19 AM.
 
Old 10-17-2012, 11:12 AM   #10
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Quote:
. any thing else you guys can see ???
  1. A severe lack of indentation.
  2. Single letter variable names, you can and should use words.
  3. The brace around line 85 should go after the switch, not case.
  4. You have an empty pair of braces at the end of main() for no apparent reason.
  5. EVERY function ends with "return main();", WHY????

EDIT: it occurs to me that maybe you thought "return main();" means return to main(), actually it means, call main() and return its result to the caller. If you just want to return from a function, a plain "return;" will suffice (although it's redundant at the end of a void function).

Last edited by ntubski; 10-17-2012 at 11:20 AM.
 
1 members found this post helpful.
Old 10-17-2012, 11:24 AM   #11
user9697
LQ Newbie
 
Registered: Oct 2012
Posts: 28

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ntubski View Post
  1. A severe lack of indentation.
  2. Single letter variable names, you can and should use words.
  3. The brace around line 85 should go after the switch, not case.
  4. You have an empty pair of braces at the end of main() for no apparent reason.
  5. EVERY function ends with "return main();", WHY????
hehe go easy on me ... does 1,2,4 and5 have to be corrected for it to function ? i would mostly like to just know am compiling the correct way so i can continue to learn .. i had no idea i had broken so many rules dev cpp din't seem to find any errors .
 
Old 10-17-2012, 11:35 AM   #12
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Quote:
Originally Posted by user9697
does 1,2,4 and5 have to be corrected for it to function ?
  • You don't need correct indentation, but it makes it much easier to see other errors (the only way I could see your other problems was to copy the code into Emacs and indent everything).
  • You don't need meaningful variable names, but it makes it much easier to see what the program is doing.
  • I think the empty pair of braces is harmless, but it's confusing.

About the "return main();"s, you can compile successfully with them, but your program will get stuck in an infinite loop overflow the stack at run time as mentioned by previous posters. I think you may have misunderstood what it means, see the EDIT in my previous post.

Last edited by ntubski; 10-17-2012 at 11:38 AM. Reason: return main(); won't really cause an infinite loop.
 
Old 10-17-2012, 11:35 AM   #13
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Quote:
Originally Posted by user9697 View Post
hehe go easy on me ... does 1,2,4 and5 have to be corrected for it to function ? i would mostly like to just know am compiling the correct way so i can continue to learn .. i had no idea i had broken so many rules dev cpp din't seem to find any errors .
Number 5 is critical; the others are just aesthetics to make your code easier to read/maintain.
 
Old 10-17-2012, 12:02 PM   #14
user9697
LQ Newbie
 
Registered: Oct 2012
Posts: 28

Original Poster
Rep: Reputation: Disabled
thx all , let me go over al report back . i will do every thing exept perhaps the full name variables atleast not untill its fully debuged
 
Old 10-18-2012, 12:05 AM   #15
user9697
LQ Newbie
 
Registered: Oct 2012
Posts: 28

Original Poster
Rep: Reputation: Disabled
ok did some editing this morning .... MORE errors ...

:~/cp$ c++ main.cpp -o main
main.cpp:7:5: warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x [enabled by default]
main.cpp:9:1: error: expected primary-expression before ‘float’
main.cpp:9:1: error: expected ‘}’ before ‘float’
main.cpp:9:1: error: expected ‘,’ or ‘;’ before ‘float’
main.cpp:23:1: error: ‘cout’ in namespace ‘std’ does not name a type
main.cpp:31:1: error: ‘cin’ does not name a type

i have spent a lot of time looking at these lines ,
9, 23 and 31. 7 doesn't seem to be something wrong with the code i just don't know what gnu++ox is ?? and how to enable it .

here is the revision
Code:
#include <cstdlib>
# include <iostream>
using namespace std;
int temps;
int heavy;
int main 
{
float a;
char b;
float c;
float d;
float e;
float f;
float g;
float h;
float i;
float j;
float k;
float l; 
int u =1;
int n;
std::cout << "ENTER 1 TO USE THE DIST CONVERTER >><< ENTER 2 TO USE THE TEMP CONVERTER" 
<< 
endl
<<"ENTER 3 TO USE WEIGHT CONVERTER, ENTER ANY OTHER # TO EXIT" << 
endl
<< "CHOSE A CONVERTER"
<< 
std::endl;
cin >> (n) 

if (n <= 3 && n >=1)
{
if ( n == 3)
   heavy();
else if (n==2)
  temps();    
if (n == 1)
     
while (u == 1)
{
cout << "---------------------------------------" <<       
endl << "WELCOME TO THE C.M.D DIST CONVERTER"  <<
endl << "***************************************" <<
endl << "* miles to km.> k" <<
endl << "*km to miles >> m" <<
endl << "*yard to metre> M        ********************************************************" <<
endl << "* metre to yard>y        **  *     *     *    *     *     *     *     *     *  **" <<
endl << "*foot to metre> t        **  *     *     *    *     *     *     *     *     *  **" <<
endl << "*metre to foot> T        ********************************************************" << 
endl <<"*foot to cm    > f     " <<
endl <<"*cm to foot    > c" <<
endl <<"* inch to cm   > i      " <<
endl <<"*cm to inch>c  > n" <<
endl << "-----------------"<< 
endl <<"ENTER FUNCTION KEY " <<
endl <<"-------------------" <<
endl;

cin >>(b);
cout <<" ENTER THE DISTANCE" << endl
 << "___________________ " << endl;
cin >> (a);

(c) = (a)*1.609;
(d) = (a)/.5936133;
(e) = (a)/1.09;
(f) = (a)*1.09;
(g) = (a)/0.3028;
(h) = (a)*30.48;
(i) = (a)*3.2808399;
(j) = (a)*0.0328084;
(k) = (a)*2.54;
(l) = (a)*0.3937008;

switch (b)

case 'k' :
     {
     cout << (c) << "    KM" << endl
      << "__________________________________" << endl;
     break;
     
case 'm' :
     cout << (d) << "   MILES" << endl <<
      "________________________________" << endl;
     break;  
     
case 'M' :
     cout << (e) << "   METRE" << endl <<
      "__________________________________" << endl;
     break;        
case 'y' :
     cout << (f) << "   YARD" << endl <<
      "____________________________________" << endl;
     break;     
case 't' :
     cout << (g) << "   METRE" << endl <<
      "___________________________________" << endl;
     break; 
     
case 'T' :     
     cout << (i) << "  FEET" << endl <<
      "____________________________________" << endl;
     break; 
case 'f' :
     cout << (h) << "  CM" << endl <<
      "______________________________________" << endl;
     break;    
case 'c' :      
  cout << (j) << "    FEET" << endl <<
   "______________________________________" << endl;
  break;       
case 'i' :
     cout << (k)  << "    CM" << endl << 
     "_____________________________________" << endl;
     break;
case 'n' :
     cout << (l)  << " INCH" << endl <<
      "______________________________________" << endl;
     break;            
     
default :
        cout << " WRONG KEY PLEASE TRY AGAIN !!!"<< endl;
        }
        cout << " ENTER 1 TO CONTINUE >>><<< ENTER ANY OTHER # TO GO TO MAIN MENU" << endl
         << "-------------------------" <<endl;
        cin >> (u);
}
 
  system("pause");
return;



int temps()
{
float a;
char b;
float c;
float d;
float e;
float f;
int i = 1;
 const float g =1.8;
 while (i == 1)
 {
cout
<<"##############################################################################" << endl 
<<"WELCOME TO THE C.M.D TEMP CONVERTER " << endl
<<"******************************************************************************" << endl
<<"When prompted for unit                     *********      *********                 " << endl
<<"                                         *********        *******     " << endl
<<"Enter f to convert celcius to farenheit ****             **  **        " << endl 
<<"*************************************** ****            **  **          " << endl 
<<"Enter c to convert farenheit to celcius ****           **  ** ***********         " << endl
<<"**************************************** ********     **  **  **********          " << endl
<<"Enter temp                                 *******  **   **   ****           " << endl 
<<"----------                                         **    **   ********            " << endl
<<"                                                   **    **   ******** *******           "<< endl
<<"                                                    *****     ****    ***   *** " << endl
<<"                                                              ****   ***     *** " << endl
<<"                                                              ****    ***   *** " << endl
<<"                                                              ****      ***** " << endl;
cin >> (e);
cout << "ENTER UNIT" << endl <<"-----------";
cin >> b;
  c = (e)*(g)+32;
  d = (e)*.5555557-18;
 
switch (b)
{
case 'f' :
     
     cout << (c) << "   fahrenheit" << endl
      << "----------------------------------------------" << endl;
break;

case 'c' :
     cout << d << " celcius" << 
     endl << "-----------------------------------------------" << endl;

}     
cout <<"TO CONTINUE ENTER 1 >><<< TO go to MAIN MENU ENTER ANY OTHER NUMBER" <<
 endl <<"-----------------------------------------------------";
cin >> (i);
}
return main();
}
/* ************************************************************************************************************************************************************************** */
/* ************************************************************************************************************************************************************************** */

int heavy
{
float a;
float b;
float c;
float d;
float e;
float f;
float g;
float h;
float i;
float j;
float l;
int q =1;

while (q == 1)
{
char k;
cout <<"############################################" << endl
<< "WELCOME TO THE C.M.D WEIGHT CONVERTER >>><<<" << endl
<<"********************" <<
endl <<"|pound to kilo-->k                ***      ****      ***                   " <<
endl <<"|kilo to pound-->p             **************************                     " <<
endl <<"|ounce to gram-->g               ***       **       ***       " <<
endl <<"|gram to ounce-->o                *        **        *    " <<
endl <<"|carat to gram-->G                *        **        *     " <<
endl <<"|gram to carat-->t             *******     **     *******                 " << 
endl <<"|stone to kilo-->K              *****      **      *****               " << 
endl <<"kilo to stone--->s                *****      **      *****             " <<
endl <<"pound to tone--->t               *****      **      *****               " <<
endl <<" tone to pound-->P                         **             " << endl 
     <<"*******************                     *********                          " <<
 endl <<"ENTER UNITS                           *************                       " <<
 endl <<"-------------------                 *****************"<< endl;
cin >> (k);
cout <<"*************************" << endl << "ENTER THE AMOUNT" << endl <<"-------------"<<endl;
cin >> (a);
(b) =(a)*0.4536;
(c) =(a)*2.2045855;
(d) =(a)*28.35;
(e) =(a)*0.0352734;
(f) =(a)*0.2;
(g) =(a)*5;
(h) =(a)*0.157473;
(i) =(a)*6.3502932;
(j) =(a)*0.0004;
(l) =(a)*2500;

 switch (k)
{ 
case 'k' :
      cout << (b) << "   KILOS" << endl
       <<"--------" << endl;
      break;
case 'p' :
      cout << (c) << "   pounds" << endl
       <<"---------" << endl;
      break;
case 'g' :
     cout << (d) << "   grams" << endl 
     << "--------" << endl;
     break;
case 'o' :
     cout <<(e) << "   ounces" << endl <<
      "---------" << endl;
     break;
case 'G':
     cout << (f) <<"   grams" << endl << 
     "---------" << endl;
     break;
case 'c' :
     cout << (g) <<"   carats" << endl <<
      "---------" << endl;
     break;

case 'K' :
     cout << (i) << "   kilos" << endl <<
     "---------" << endl;
     break;                           
case 's' :
     cout << (h) << "   stones" << endl <<
     "---------" << endl;
     break;
case 't' :
     cout << (j) << "   tones" << endl <<
      "--------" << endl;
     break;



}
cout << "ENTER 1 TO CONTINUE >><< ENTER ANY OTHER NUMBER TO RETURN TO MAIN MENU" << endl
 <<"**********************************************************************";
cin >> (q);     
}
return;
}
line 9:1
Code:
 int main 
{
float a;
char b;
line 23:1
Code:
 int n;
std::cout << "ENTER 1 TO USE THE DIST CONVERTER >><< ENTER 2 TO USE THE TEMP CONVERTER" 
<<
line 31 is similar to 23 so if i can figure out what am doing wrong there al prolly need to edit all my cout and cin ops ..
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
A compiling question neily Linux - Security 1 09-24-2006 05:22 PM
compiling 2.6.8.1 question noxious Slackware 11 09-29-2004 04:34 PM
g++ Compiling Question ErikJohnson Linux - General 9 04-01-2004 07:48 AM
compiling question glo Linux - Newbie 0 07-28-2003 10:50 AM
Compiling Question fotoguy Linux - Software 0 05-24-2003 04:41 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration