hello people I just started to learn C++ 3 days ago, I am just 13 yrs old

I have made this basic maths utility tool or you can call it a calculator but it tells everything, multiplication, division, addition, subtraction at once.

// if you could help me with it it would be amazing.
// please help me by typing the code as I started to learn it 3 days ago
// there might be some stuff like if, which is of no use I just added it by mistake
//This code was written in Code::Blocks
#include <iostream>

using namespace std;

int main()
{
  float numb1, numb2, result;
  char symbol;
  cout<<"Please enter first number: ";
  cin>> numb1;
  cin.ignore();
  cout<<"You entered: "<< numb1 <<"\n";
  cout<<"your second number";
      cin>> numb2;
      cin.ignore();
      cout<<"You entered: "<< numb2 <<"\n";
cout <<"................................................................................\n";
     if ("symbol = +")
     result = numb1 + numb2;
      cout<<"the sum is :"<< result <<"\n";
cout <<".........................................................................................\n";
      if ("symbol = -")
      result = numb1 - numb2;
      cout<<"the difference is:"<< result <<"\n";
cout <<"..........................................................................................\n";
      if ("symbol = /")
      result = numb1 / numb2;
      cout<<"the quotient is:"<< result <<"\n";
cout <<"...........................................................................................\n";
      if ("symbol = *")
      result = numb1 * numb2;
      cout<<"the product is:"<< result <<"\n";
      cout <<"................................................................................\n";
cout <<"made by vikram sehgal\n";

  cin.get();
}

Hey,

Everything appears to work, up to the fact that:

1) You don't ask for the input for the mathemtical operator (+, -, / etc..)

    cin >> symbol;

2) Your conditional if statements are wrong, they should be like:

  if(symbol == '+')
  {
      cout << "Add";
  }

You should consider case switch statements for this program, I think it would make things a lot easier (IMO). Hope this helps :)

commented: I tried it is still the same +0

if ("symbol = +")

When doing comparisons you have to use == operator, what you have above is an assignment operator. Don't get the two operators confused even though they look alot alike.

Second problem with the above line is remove the quotes and put ' around the + symbol. Here's how it should look.
if( symbol == '+')

Next, use { and } to enclose multi-line statements such as those if statements in your program.

if (symbol == '+')
{
     result = numb1 + numb2;
      cout<<"the sum is :"<< result <<"\n";
}
commented: I tried it is still the same +0

I tried it but it showed an error I

but still thanks a lot I will try it again.
This calculator was made in notepad try it.
copy and paste it in notepad and save it as .bat

@echo off
:hom
title Calculator
echo Welcome %USERNAME%, Please Type a number.
set/p one=
cls
echo Type the sign. (+,-,*,/)
set/p two=%one%...
echo And type the last number.
set/p three=%one%%two%...
set/a final=%one%%two%%three%
cls
echo Total: %one%%two%%three%=%final%
pause
cls
echo THIS IS MADE BY VIKRAM SEHGAL
goto hom

@GokuLSSJ4

Post the updated code, which is giving you the error

commented: here i posted the updated code +0

Here this is the code for it

// there was some string or cstring stuff on the internet I don't completely remember it
// I tried it with that also but still it wasnt working
#include <iostream>

using namespace std;

int main()
{
  float numb1, numb2, result;
  char symbol;
  cout<<"Please enter first number: ";
  cin>> numb1;
  cin.ignore();
  cout<<"You entered: "<< numb1 <<"\n";
  cout<<"your second number";
      cin>> numb2;
      cin.ignore();
      cout<<"You entered: "<< numb2 <<"\n";
cout <<"................................................................................\n";
     if (symbol == '+')
     result = numb1 + numb2;
      cout<<"add";
cout <<".........................................................................................\n";
      if (symbol == '-')
      result = numb1 - numb2;
      cout<<"subtract";
cout <<"..........................................................................................\n";
      if (symbol == '/')
      result = numb1 / numb2;
      cout<<"divide";
cout <<"...........................................................................................\n";
      if (symbol == '*')
      result = numb1 * numb2;
      cout<<"multiply";
      cout <<"................................................................................\n";
cout <<"made by vikram sehgal\n";

  cin.get();
}

"symbol" never gets a value.

Thanks a lot now the calculator is working perfect
.....

Here is the code

// here it is my master piece
//
#include <iostream>

using namespace std;

int main()
{
  float numb1, numb2, result;
  char symbol;
  cout<<"Please enter first number: ";
  cin>> numb1;
  cout<<"You entered: "<< numb1 <<"\n";
cout<<"Please enter second number: ";
  cin>> numb2;
  cout<<"You entered: "<< numb2 <<"\n";
  cout<<"Choose your function '+, -, /, *' \n";
  cin>> symbol;
  if (symbol == '+')
  result = numb1 + numb2;
  if (symbol == '-')
  result = numb1 - numb2;
  if (symbol == '*')
  result = numb1 * numb2;
  if (symbol == '/')
  result = numb1 / numb2;
  cout<<"The result is "<<numb1<<symbol<<numb2<<"=" <<(result);
  cin.get();
}

hello phorce and ancient dragon and nick evan.....
if you people could explain me how to insert and show pictures/ photos in C++

it would be great....
I know that opengl, OPEN Vc , Pointer are used for it (any of these)
but I don't know how to use them

PLS HELP ME!!!!!!!

There are lots of online tutorials, just google for them (click here).

hello people this is the percentage finder try it out >>>

//the percentage finder
#include <iostream>

using namespace std;

int main()
{
   float numb1, numb2, numb3, result;
   char symbol;

   cout<<"Please enter your marks:";
   cin>>numb1;
   cin.ignore();

   cout<<"Please enter the total marks of the test:";
   cin>>numb2;
   cin.ignore();

   numb3 = 100;
   result = numb1/numb2*numb3;
   cout<<"your percentage is:"<< result <<"%"<<"\n";

   cin.get();
}
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.