#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

Recommended Answers

All 11 Replies

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()
#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...

thanks alot! it work now... :)

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...

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

u hv not written void main()

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

thanks alot!

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;
}
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.