-1
#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

7
Contributors
11
Replies
12
Views
7 Years
Discussion Span
Last Post by lsandling
Featured Replies
  • 1
    WaltP 2,905   7 Years Ago

    [QUOTE=sdh;1114458]the prototype of main is already written in the header files.[/QUOTE]He said it was solved. [QUOTE=sdh;1114463]u hv not written void main()[/QUOTE] No he not wrtn tht. Dun writ leet spk, use ful engsh so ppl wth bd englsh cn unnerstnd. This is part of the [url=http://www.daniweb.com/techtalkforums/faq.php?faq=daniweb_policies]Forum Rules[/url]. Read More

0

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 by thomas_naveen: n/a

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

0

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 by enderes05: n/a

0

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

0

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

Edited by vidit_X: n/a

1

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.

0

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.
Be sure to adhere to our posting rules.