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

void add(){
clrscr();
int a,b,c;
	cout<<"Enter number:"<<endl;
	cin>>a;
	cout<<"Enter number:"<<endl;
	cin>>b;

	c=a+b;
	cout<<"The total is: "<<c<<endl;
getch();
clrscr();
}

void sub(){
clrscr();
int a,b,c;
	cout<<"Enter number:"<<endl;
	cin>>a;
	cout<<"Enter number:"<<endl;
	cin>>b;
	c=a-b;
	cout<<"The total is: "<<c<<endl;
getch();
clrscr();
}

void mul(){
clrscr();
int a,b,c;
	cout<<"Enter number:"<<endl;
	cin>>a;
	cout<<"Enter number:"<<endl;
	cin>>b;
	c=a*b;
	cout<<"The total is: "<<c<<endl;
getch();
clrscr();
}

void div(){
clrscr();
float a,b,c;
	cout<<"Enter number:"<<endl;
	cin>>a;
	cout<<"Enter number:"<<endl;
	cin>>b;
	c=a/b;
	cout<<"The total is: "<<c<<endl;
if(b>a){
	c=b/a;
	cout<<"The total is: "<<c<<endl;

getch();
clrscr();
}

main(){
clrscr();
char choice;

do{
cout<<"~MENU~";
cout<<"[a] Addition"<<endl;
cout<<"[b] Subtraction"<<endl;
cout<<"[c] Multiplication"<<endl;
cout<<"[d] Division"<<endl;
cout<<"[e] Exit~"<<endl;
cin>>choice;

switch(choice){

	case'a':
		add();
		break;
	case'b':
		sub();
		break;
	case'c':
		mul();
		break;
	case'd':
		div();
		break;
	default:
		cout<<"Try Again!"<<endl<<endl;

}}while(choice!='e');
	cout<<"Thank You!";
getch()
return 0;
}

it says that 'main' got no protocol... please help about this... T_T

There is no need to beg.

Looks like

void div(){

is not getting closed.

Put one more curly brace before main()

[EDIT]

use

int main()

Edited 6 Years Ago by thomas_naveen: n/a

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

void add(){
clrscr();
int a,b,c;
	cout<<"Enter number:"<<endl;
	cin>>a;
	cout<<"Enter number:"<<endl;
	cin>>b;

	c=a+b;
	cout<<"The total is: "<<c<<endl;
getch();
clrscr();
}

void sub(){
clrscr();
int a,b,c;
	cout<<"Enter number:"<<endl;
	cin>>a;
	cout<<"Enter number:"<<endl;
	cin>>b;
	c=a-b;
	cout<<"The total is: "<<c<<endl;
getch();
clrscr();
}

void mul(){
clrscr();
int a,b,c;
	cout<<"Enter number:"<<endl;
	cin>>a;
	cout<<"Enter number:"<<endl;
	cin>>b;
	c=a*b;
	cout<<"The total is: "<<c<<endl;
getch();
clrscr();
}

void div(){
clrscr();
float a,b,c;
	cout<<"Enter number:"<<endl;
	cin>>a;
	cout<<"Enter number:"<<endl;
	cin>>b;
	c=a/b;
	cout<<"The total is: "<<c<<endl;
if(b>a){
	c=b/a;
	cout<<"The total is: "<<c<<endl;

getch();
clrscr();
}

main(){
clrscr();
char choice;

do{
cout<<"~MENU~";
cout<<"[a] Addition"<<endl;
cout<<"[b] Subtraction"<<endl;
cout<<"[c] Multiplication"<<endl;
cout<<"[d] Division"<<endl;
cout<<"[e] Exit~"<<endl;
cin>>choice;

switch(choice){

	case'a':
		add();
		break;
	case'b':
		sub();
		break;
	case'c':
		mul();
		break;
	case'd':
		div();
		break;
	default:
		cout<<"Try Again!"<<endl<<endl;

}}while(choice!='e');
	cout<<"Thank You!";
getch()
return 0;
}

it says that 'main' got no protocol... please help about this... T_T

just add int main() it may work...

can you help me? what if, after choosing add, sub, div or multi. then "Enter number:" and i put letters, and it should say that "Invalid! Try Again..."
what should i do? please help me! this is my project... and sorry for my english...

Edited 6 Years Ago by enderes05: n/a

the prototype of main is already written in the header files.

Put a check on the input numbers before operating on them.

Edited 6 Years Ago by vidit_X: n/a

the prototype of main is already written in the header files.

He said it was solved.

u hv not written void main()

No he not wrtn tht. Dun writ leet spk, use ful engsh so ppl wth bd englsh cn unnerstnd. This is part of the Forum Rules.

What do I know I am a newbie too but this worked for me. Heck I not sure if I am posting this right.

#include<iostream>
#include<conio.h>
using namespace std;


void add(){
system("cls");
int a,b,c;
	cout<<"Enter number:"<<endl;
	cin>>a;
	cout<<"Enter number:"<<endl;
	cin>>b;

	c=a+b;
	cout<<"The total is: "<<c<<endl;
getch();
system("cls");
}

void sub(){
system("cls");
int a,b,c;
	cout<<"Enter number:"<<endl;
	cin>>a;
	cout<<"Enter number:"<<endl;
	cin>>b;
	c=a-b;
	cout<<"The total is: "<<c<<endl;
getch();
system("cls");
}

void mul(){
system("cls");
int a,b,c;
	cout<<"Enter number:"<<endl;
	cin>>a;
	cout<<"Enter number:"<<endl;
	cin>>b;
	c=a*b;
	cout<<"The total is: "<<c<<endl;
getch();
system("cls");
}

void div(){
system("cls");
float a,b,c;
	cout<<"Enter number:"<<endl;
	cin>>a;
	cout<<"Enter number:"<<endl;
	cin>>b;
	c=a/b;
	cout<<"The total is: "<<c<<endl;
if(b>a){
	c=b/a;
	cout<<"The total is: "<<c<<endl;

getch();
system("cls");
}
}

int main()
{
system("cls");
char choice;

do{
cout<<"~MENU~";
cout<<"[a] Addition"<<endl;
cout<<"[b] Subtraction"<<endl;
cout<<"[c] Multiplication"<<endl;
cout<<"[d] Division"<<endl;
cout<<"[e] Exit~"<<endl;
cin>>choice;

switch(choice){

	case'a':
		add();
		break;
	case'b':
		sub();
		break;
	case'c':
		mul();
		break;
	case'd':
		div();
		break;
	default:
		cout<<"Try Again!"<<endl<<endl;

}}while(choice!='e');
	cout<<"Thank You!";
getch();
return 0;
}
This article has been dead for over six months. Start a new discussion instead.