Hi all

I am using a tutorial on youtubehttp://www.youtube.com/watch?v=sIy3oOguh_0&mode=related&search= and it is going well apart from I can't compile the latest program, a calcualtor
my compiler (devC/C++) keeps highlighting the endl; near the end of the code, i have placed a comment above it. I have checked the video many times but I cannot find the problem, but the quality of the video is poor so I might have missed something. Can somebody please help me and tell me what is wrong with the code?

#include<iostream>
using namespace std;
int main(void)
{
    system("TITLE Calculator");
    system("COLOR 2");
 
    // Declare Variables
    char cChar;
    double dfirstnumber;
    double dsecondnumber;
    char cDoagain;
 
    do
    {
         system("CLS");
         cout << "please enter the first number you would like to use"
         << endl;
         cin >> dfirstnumber;
 
         cout << "please enter the operation that you would like to complete"
              << "(+,-,* or /)" << endl;
              cin >> cChar;
 
              cout << "please enter the second number you would like to use"
              << endl;
 
              switch (cChar)
              {
              case '+': 
              cout << "the answer is" << dfirstnumber << " + " << 
              // maths happens here
              dsecondnumber << " = " << (dfirstnumber + dsecondnumber)
              << endl;
 
              break;
 
              case '-':
              cout << "the answer is" << dfirstnumber << " - " << 
              // maths happens here
              dsecondnumber << " = " << (dfirstnumber - dsecondnumber)
              << endl;
 
              break;
 
              case '*':
              cout << "the answer is" << dfirstnumber << " * " << 
              // maths happens here
              dsecondnumber << " = " << (dfirstnumber * dsecondnumber)
              << endl;
 
              break;
 
              case 'x':
              cout << "the answer is" << dfirstnumber << " x " << 
              // maths happens here
              dsecondnumber << " = " << (dfirstnumber * dsecondnumber)
              << endl;
 
              break;
 
              case 'X':
              cout << "the answer is" << dfirstnumber << " X " << 
              // maths happens here
              dsecondnumber << " = " << (dfirstnumber * dsecondnumber)
              << endl;
 
              break;
 
              case '/':
              if(dsecondnumber == 0){
              cout << "that is an invalid operation" << endl;
              }else(
              cout << "the answer is" << dfirstnumber << " / " << 
              // maths happens here
              dsecondnumber << " = " << (dfirstnumber / dsecondnumber)
              //Problem is with endl; below PROBLEM PROBLEM PROBLEM
              << endl;
 
              }
              break;
              default;
              cout << "that is an invalid operation" << endl;
              break;
 
              }
              cout << "woudl you like to start again? (y or n)" << endl;
              cin >> cDoagain;
 
              }while (cDoagain == 'Y' || cDoagain == 'y');
              system("PAUSE");
              return 0;
 
              }

Many thanks

HLA91

>}else(
That last character is a paren, not an opening brace.

>default;
That last character is a semicolon, not a colon.

Thanks for that I did manage to sort the endl; problem but the default problem I couldn't
thanks for your help and very quick reply

HLA91

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.