Click here to Skip to main content
15,895,656 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: The questions we get these days! Pin
DarthDana27-Apr-12 9:21
professionalDarthDana27-Apr-12 9:21 
QuestionHow to add Message for dynamically created control(CListCtrl) Pin
shanmugarajaa9-Apr-12 2:13
shanmugarajaa9-Apr-12 2:13 
AnswerRe: How to add Message for dynamically created control(CListCtrl) Pin
_Flaviu9-Apr-12 5:10
_Flaviu9-Apr-12 5:10 
GeneralRe: How to add Message for dynamically created control(CListCtrl) Pin
_Flaviu9-Apr-12 21:56
_Flaviu9-Apr-12 21:56 
GeneralRe: How to add Message for dynamically created control(CListCtrl) Pin
shanmugarajaa9-Apr-12 23:04
shanmugarajaa9-Apr-12 23:04 
GeneralRe: How to add Message for dynamically created control(CListCtrl) Pin
_Flaviu10-Apr-12 4:28
_Flaviu10-Apr-12 4:28 
GeneralRe: How to add Message for dynamically created control(CListCtrl) Pin
Parthi_Appu12-Apr-12 0:25
Parthi_Appu12-Apr-12 0:25 
Questionhelp needed with my calculator code Pin
Member 87942428-Apr-12 22:48
Member 87942428-Apr-12 22:48 
I'm a total beginner with C++
The program is a calculator written with CodeBlocks

When I compile it CodeBlocks, everything works
but using Visual Studio and Visual Studio Command Line the code seems to be full of errors.

Can someone please assist me what is wrong in the code and how to fix it so that it is compatible with Visual Studio


___________________________________________________


#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
// Program discription and Legal Information
cout << ("basic calculator to allow ") << endl;
cout << ("arithmetic operations like +, -, *, / .") << endl;
cout << ("License GPL - by Dominik Schaller - 2012 \n") << endl;

// we need two variables to store the numbers for calculation
float a; // variable a - we use "float" for precission
float b; // variable b - we use "float" for precission

// we need an arithmetic operator for the calculation (+, -, *, /)
string c_operator; // operant input variable as string

// we need a variable to store the result into memory for later console output
float c; // to store the result of arithmetic operation of a and b

// now we enter the first number and store it into memory
cout << ("Enter first number and press [ENTER] to continue\n"); // type number 1
cin >> a; // read number one into variable a
cout << endl; // cleanup

// now we type the operator into the console window as string
cout << ("type operator and press [ENTER] to continue\n"); // type the operator
cin >> c_operator; // read operator as string
cout << endl; // cleanup

// now we enter the second number and store it into memory
cout << ("Enter second number and press [ENTER] to continue\n"); // type number 2
cin >> b; // read number two into variable b
cout << endl; // cleanup

// in this case we use basic if and else staements
// but we also could have used a switch staement
if (c_operator == "+") // check to see if operator is "addition"
{
c = a+b; // if so, calculate (a+b)
}

else if (c_operator == "-") // check to see if operator is "subtraction"
{
c = a-b; // if so, calculate (a-b)
}

else if (c_operator == "*") // check to see if operator is "multiplication"
{
c = a * b; // if so, calculate (a*b)
}

else if (c_operator == "/") // check to see if operator is "division"
{
c = a/b; // if so, calculate (a/b)
}

// now we print the result out to the console screen
cout << ("result is: ") << c << endl; // finally print result on console screen

system ("pause"); // prevent console from shutting down wait...
return 0;
}

____________________________________________________
AnswerRe: help needed with my calculator code Pin
Richard MacCutchan8-Apr-12 22:55
mveRichard MacCutchan8-Apr-12 22:55 
GeneralRe: help needed with my calculator code Pin
Member 87942428-Apr-12 23:15
Member 87942428-Apr-12 23:15 
GeneralRe: help needed with my calculator code Pin
Richard MacCutchan9-Apr-12 0:09
mveRichard MacCutchan9-Apr-12 0:09 
Generaljava Pin
anurag9558-Apr-12 13:54
anurag9558-Apr-12 13:54 
GeneralRe: java Pin
Wes Aday8-Apr-12 14:28
professionalWes Aday8-Apr-12 14:28 
GeneralRe: java Pin
Mohibur Rashid8-Apr-12 17:49
professionalMohibur Rashid8-Apr-12 17:49 
AnswerRe: java Pin
Malli_S8-Apr-12 19:51
Malli_S8-Apr-12 19:51 
AnswerRe: java Pin
Chuck O'Toole9-Apr-12 8:06
Chuck O'Toole9-Apr-12 8:06 
QuestionLinked List Pin
djgmad8-Apr-12 3:37
djgmad8-Apr-12 3:37 
AnswerRe: Linked List Pin
Randor 8-Apr-12 4:32
professional Randor 8-Apr-12 4:32 
GeneralRe: Linked List Pin
djgmad8-Apr-12 5:43
djgmad8-Apr-12 5:43 
GeneralRe: Linked List Pin
Randor 8-Apr-12 6:52
professional Randor 8-Apr-12 6:52 
GeneralRe: Linked List Pin
enhzflep8-Apr-12 7:24
enhzflep8-Apr-12 7:24 
AnswerRe: Linked List Pin
Erudite_Eric8-Apr-12 7:01
Erudite_Eric8-Apr-12 7:01 
SuggestionRe: Linked List Pin
David Crow8-Apr-12 16:33
David Crow8-Apr-12 16:33 
Questionc Pin
siddharth00077-Apr-12 17:23
siddharth00077-Apr-12 17:23 
AnswerRe: c Pin
Rajesh R Subramanian7-Apr-12 22:43
professionalRajesh R Subramanian7-Apr-12 22:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.