Hello, Ive started to programming a few days ago, I'm totally new never done it before.
Ive read through the internet for some knowledge about programming.

I used the program code blocks to program yesterday but I got some errors in it so I uninstalled it, it wasnt really errors but sometimes it did work to use for example "#include <iostream>" and sometimes when I did it and tryed to compile it said I didnt have iostream or something like that.

Today I watched a tutorial about programming I did exactly as him but I still got these errors, I dont know why.
Currently I'm using Dev-c++ version 4.9.9.2

Here's the errors.

Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\Makefile.win" all
g++.exe -c eeeee.cpp -o eeeee.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"

eeeee.cpp: In function `int main()':
eeeee.cpp:43: error: expected `)' before "x"

eeeee.cpp:48: error: expected `)' before "X"

eeeee.cpp:68: error: expected `while' at end of input

eeeee.cpp:68: error: expected `(' at end of input
eeeee.cpp:68: error: expected primary-expression at end of input
eeeee.cpp:68: error: expected `)' at end of input
eeeee.cpp:68: error: expected `;' at end of input
eeeee.cpp:68: error: expected `}' at end of input

make.exe: *** [eeeee.o] Error 1

Execution terminated

And here is the code i used:

#include<iostream>
using namespace std;

int main(void)
{
      
      system("TITLE Calculator");
      system("COLOR 2");
      char cChar;
      double dfirstnumber;
      double dsecondnumber;
      char cDoagain;
      
do
{
      system("CLS");
      cout << "Please enter the first number that you would like to use" << endl;
      cin >> dfirstnumber
      ;cout << "Please enter the operation 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 << " + " <<
                  dsecondnumber << " = " << (dfirstnumber + dsecondnumber)
                  << endl;
                  break;
             case '-':
                  cout << "The answer is: " << dfirstnumber << " - " <<
                  dsecondnumber << " = " << (dfirstnumber - dsecondnumber)
                  << endl;
                  break;
              case '*':
                  cout << "The answer is: " << dfirstnumber << " * " <<
                  dsecondnumber << " = " << (dfirstnumber * dsecondnumber)
                  << endl;  
                  break;
               case 'x':
                  cout << "The answer is: " << dfirstnumber << " x " <<
                  dsecondnumber << " = " << (dfirstnumber x dsecondnumber)
                  << endl;    
                  break;
               case 'X':
                  cout << "The answer is: " << dfirstnumber << " X " <<
                  dsecondnumber << " = " << (dfirstnumber X dsecondnumber) << endl;   
                  break;
               case '/':
                    if(dsecondnumber == 0) {
                                     cout << "That is an invalid operation" << endl;
                                     }else{
                  cout << "The answer is: " << dfirstnumber << " / " <<
                  dsecondnumber << " = " << (dfirstnumber / dsecondnumber)
                  << endl;    
                  }
                  break;
                  default:
                          cout << "That is an invalid operation" << endl;
                          break;
                          
                          cout << "Would you like to start again (y or no)" << endl;
                          cin >>cDoagain;
                          }while (cDoagain == 'Y' || cDoagain == 'y');
                          system("PAUSE");
                          return 0;
}

Thanks.

Problem is in the line 43 && line 48

Operator x does not exist if you want to get result of multiplication you need to use * operator instead of x

So you mean I should take away the x and X? since it can't be used?

Yeah basically thats what they are saying and i have found additional formating things and some bugs in functionality.

my code below

Attachments
#include <iostream>

using namespace std;



int main(void)
{
	system("TITLE Calculator");

	system("COLOR 2");
	char cChar;

	double dfirstnumber;

	double dsecondnumber;

	char cDoagain;

	do
	{

		system("CLS");

		cout << "Please enter the first number that you would like to use" << endl;

		cin >> dfirstnumber; //moved semicolon to correct place

		cout << "Please enter the operation you would like to complete" << " (+,-,* or /)" << endl;

		cin >> cChar;


		cout << "Please enter the second number you would like to use" << endl;
		//not geting a character here so program continues
		cin >>dsecondnumber;
		
		switch (cChar)

		{

			case '+':
				cout << "The answer is: " << dfirstnumber << " + " << dsecondnumber;
				cout << " = " << (dfirstnumber + dsecondnumber) << endl; //broke into 2 cout's to split line
				break;

			case '-':
				cout << "The answer is: " << dfirstnumber << " - " << dsecondnumber;
				cout<< " = " << (dfirstnumber - dsecondnumber) << endl;
				break;

			case '*':
				cout << "The answer is: " << dfirstnumber << " * " << dsecondnumber;
				cout << " = " << (dfirstnumber * dsecondnumber) << endl;
				break;

		/*	case 'x':
				cout << "The answer is: " << dfirstnumber << " x " << dsecondnumber;
				cout << " = " << (dfirstnumber x dsecondnumber) << endl; //x? there is no operator for the character x
				break;
		*/

	   	/*	case 'X':
				cout << "The answer is: " << dfirstnumber << " X " << dsecondnumber << " = ";
				cout << (dfirstnumber X dsecondnumber) << endl; //same here
				break;
		*/

			case '/':
				if(dsecondnumber == 0)//dont want divide by 0
				{
					cout << "That is an invalid operation" << endl;
				}
				else
				{
					cout << "The answer is: " << dfirstnumber << " / " << dsecondnumber;
					cout << " = " << (dfirstnumber / dsecondnumber) << endl;

				}
				break;

				default:
					cout << "That is an invalid operation" << endl;
					break;

		} //there was no end switch brace here

		cout << "Would you like to start again (y or no)" << endl;

		cin >>cDoagain;

	} while (cDoagain == 'Y' || cDoagain == 'y');

	system("PAUSE");

	return 0;

}

I did take away the x and X

but I still get this error:
ompiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\Makefile.win" all
g++.exe -c eeeee.cpp -o eeeee.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"

eeeee.cpp: In function `int main()':
eeeee.cpp:60: error: expected `while' at end of input
eeeee.cpp:60: error: expected `(' at end of input

eeeee.cpp:60: error: expected primary-expression at end of input
eeeee.cpp:60: error: expected `)' at end of input
eeeee.cpp:60: error: expected `;' at end of input
eeeee.cpp:60: error: expected `}' at end of input

make.exe: *** [eeeee.o] Error 1

Execution terminated

Yeah I just saw yours code, and I tryed to compile it and it actually did work! Thanks alot man, I'm totally new to this, so sorry for being a noob :p

Which program would you recommand to be using? Dev-c++ version 4.9.9.2 or something else?

Do you got any advices where I should start learning? atm I'm just looking on video tutorials and doing the same as them, trying to learn something, but I dont really know the basics, I mean what code, to use and so on, Ive read about Strings, variables, but I don't really get It.

Also, how could the guy in the tutorial actually include "x" and "X" in his code, when I couldn't?

Here's the tutorial.

Part 1:
http://www.youtube.com/watch?v=nziy2_U5JQI&feature=player_embedded

Part 2:
http://www.youtube.com/watch?v=FPKmFdNP5_A&feature=player_embedded

Ok well he used the character 'x' or 'X' as part of the switch statement but in the actual evaluation in the cout he used the * (multiplication) as in

case 'x': num1 * num2 ;

you had did

case'x': num1 x num2;

basically he was expecting the user on occasion to use the character X or x to mean multiply and handling that.

To learn C++ there is a section of recomended books in the c++ forum page (where you were to create this thread) and it lists great books to learn from. try to avoid things like teach yourself in like 6 hours or silly things like that they suck.

so check that page out for some good books ok :)

Hope this helps you and good luck in future

edit:
I checked the video link ,...... "you have 2 number formats in the most part int and double" i disagree i use 99% of the time unsigned ints and floats :P so i dont like that guy or agree with him

Thus enforcing above point get a good book not some attempt at a quick and easy way to learn book or resource

Edited 6 Years Ago by Kanoisa: n/a

Thanks alot Kanosia for your help i appreciate it alot! :)

So basically I got it wrong since i put x in the (dfirstnumber x dsecondnumber) I should let it been * there, am I right?

Thanks, I'm going to try buy some books about programming.

I havent been reading any learn in some hours stuff, Ive read through everything, from the beginning, but I don't get some things since English isn't my main language, It is Swedish, and some words In english I don't even understand in Swedish :p

havent been reading any learn in some hours stuff

Was just incase you seen those sams teach yourself in 21 days and all those silly books avoid them.

and yes the correct usage is shown below.

(dfirstnumber * dsecondnumber)//correct
(dfirstnumber X dsecondnumber)//incorrect

Good luck with the coding in future, with english as a second language too ,... must be tough, but im sure you will get there :)

This article has been dead for over six months. Start a new discussion instead.