Click here to Skip to main content
15,921,989 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalsomething like that8) Pin
realfly11-Jul-03 21:35
realfly11-Jul-03 21:35 
GeneralRe: something like that8) Pin
hongge11-Jul-03 23:15
hongge11-Jul-03 23:15 
GeneralRe: something like that8) Pin
realfly13-Jul-03 15:40
realfly13-Jul-03 15:40 
GeneralNeed some help(Beginner) Pin
Fightingbee11-Jul-03 19:43
Fightingbee11-Jul-03 19:43 
GeneralRe: Need some help(Beginner) Pin
Michael Dunn11-Jul-03 20:09
sitebuilderMichael Dunn11-Jul-03 20:09 
GeneralRe: Need some help(Beginner) Pin
Fightingbee11-Jul-03 20:21
Fightingbee11-Jul-03 20:21 
GeneralRe: Need some help(Beginner) Pin
Michael P Butler11-Jul-03 21:43
Michael P Butler11-Jul-03 21:43 
GeneralRe: Need some help(Beginner) Pin
Fightingbee12-Jul-03 5:54
Fightingbee12-Jul-03 5:54 
Well ok here is the copy of the changed code,

#include<iostream>
#include<conio.h>

using namespace std;

int sum = 0;
int ssum = 0;
int msum = 0;
double dsum = 0;
int x = 0;
int y = 0;
int menu();
int c = menu();

int main()
{	
	do
	{
		menu();

		if(c == 1)
			 add();
		else if(c == 2)	
			 sub();
		else if(c == 3)
			 multi();
		else if(c == 4)
			 div();
	}

	while(c == 5);
		cout<<"Thank you for using the calculator!"<<endl;
		
	getch();
	return 0;
}
		 
menu()
{	
	int sel = 0;

    cout<<"Please select a menu choice..."<<endl
    <<"1. Add"<<endl
    <<"2. Subtract"<<endl
    <<"3. Multiply"<<endl
    <<"4. Divide"<<endl
    <<"5. Exit program"<<endl;
		cin>>sel;
		
	if(c > 5 && c < 1)
		cout<<"You have entered an invalid selection!"<<endl;

	return sel;
}

int add()
{
        cout<<"Please enter a number..."<<endl;
		cin>> x;
		cout<<"Please enter your second number..."<<endl;
		cin>>y;

		sum = x + y;
		cout<<"The answer is "<<sum<<endl;

	    return sum;
}

int sub()
{
        cout<<"Please enter a number..."<<endl;
		cin>> x;
		cout<<"Please enter your second number..."<<endl;
		cin>>y;
	
		ssum = x - y;
		cout<<"The answer is "<<ssum<<endl;

	    return ssum;
}

int multi()
{
		cout<<"Please enter a number..."<<endl;
		cin>> x;
		cout<<"Please enter your second number..."<<endl;
		cin>>y;
	
		msum = x * y;
		cout<<"The answer is "<<msum<<endl;

		return msum;
}

double div()
{
		cout<<"Please enter a number..."<<endl;
		cin>> x;
		cout<<"Please enter your second number..."<<endl;
		cin>>y;
	
		dsum = x / y;
		cout<<"The answer is "<<dsum<<endl;

		return dsum;
}



And here are the errors it is throwing up,

--------------------Configuration: assign4 - Win32 Debug--------------------
Compiling...
assign4.cpp
D:\Assignment 4\assign4.cpp(33) : error C2065: 'add' : undeclared identifier
D:\Assignment 4\assign4.cpp(35) : error C2065: 'sub' : undeclared identifier
D:\Assignment 4\assign4.cpp(37) : error C2065: 'multi' : undeclared identifier
D:\Assignment 4\assign4.cpp(39) : error C2660: 'div' : function does not take 0 parameters
D:\Assignment 4\assign4.cpp(68) : error C2373: 'add' : redefinition; different type modifiers
D:\Assignment 4\assign4.cpp(81) : error C2373: 'sub' : redefinition; different type modifiers
D:\Assignment 4\assign4.cpp(94) : error C2373: 'multi' : redefinition; different type modifiers
Error executing cl.exe.

assign4.obj - 7 error(s), 0 warning(s)

GeneralRe: Need some help(Beginner) Pin
Snyp12-Jul-03 6:33
Snyp12-Jul-03 6:33 
GeneralChanging Font Pin
Kristian Kratzenstein11-Jul-03 19:39
Kristian Kratzenstein11-Jul-03 19:39 
GeneralRe: Changing Font Pin
hongge11-Jul-03 20:29
hongge11-Jul-03 20:29 
GeneralRe: Changing Font Pin
Kristian Kratzenstein11-Jul-03 21:10
Kristian Kratzenstein11-Jul-03 21:10 
GeneralRe: Changing Font Pin
pranavamhari11-Jul-03 22:35
pranavamhari11-Jul-03 22:35 
GeneralRe: Changing Font Pin
Kristian Kratzenstein12-Jul-03 6:21
Kristian Kratzenstein12-Jul-03 6:21 
GeneralOn Un-minimizing information stored in array is not shown. Pin
Terry Eff11-Jul-03 19:04
Terry Eff11-Jul-03 19:04 
Questionhow text can display in spiral form Pin
Member 47204511-Jul-03 15:01
Member 47204511-Jul-03 15:01 
AnswerRe: how text can display in spiral form Pin
Anthony_Yio15-Jul-03 1:23
Anthony_Yio15-Jul-03 1:23 
AnswerRe: how text can display in spiral form Pin
Anthony_Yio15-Jul-03 1:23
Anthony_Yio15-Jul-03 1:23 
Questionwhat is the different between the DLL and application Pin
gdzfy11-Jul-03 14:33
gdzfy11-Jul-03 14:33 
AnswerRe: what is the different between the DLL and application Pin
gdzfy11-Jul-03 14:34
gdzfy11-Jul-03 14:34 
GeneralRe: what is the different between the DLL and application Pin
John M. Drescher11-Jul-03 17:49
John M. Drescher11-Jul-03 17:49 
GeneralRe: what is the different between the DLL and application Pin
Snyp12-Jul-03 6:37
Snyp12-Jul-03 6:37 
GeneralThreads and ~Component Pin
Paul Farry11-Jul-03 14:31
professionalPaul Farry11-Jul-03 14:31 
GeneralRe: Threads and ~Component Pin
Ryan Binns11-Jul-03 16:05
Ryan Binns11-Jul-03 16:05 
GeneralContext Menu Cursor Problem Pin
dWorkVan11-Jul-03 13:55
dWorkVan11-Jul-03 13:55 

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.