Find the error in this C++ program and submit a working program.
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Find the error in this C++ program and submit a working program.
#include <math.h>
int adition (int num1, int num2);
int subtration (int num1, int num2);
int multiplication (int num1, int num2);
int division (int num1, int num2);
int remainder (int num1 int num2);
int main();
{
char option;
int num1,num,result;
float sqr;
cout<<"\n\t\t\tSimple Calculator"<<endl;
do
{
cout<<" Enter + for Addition\n Enter - for Subtraction\n Enter * for Multiplication\n Enter / for Division\n Enter R for Remainder\n Enter E to EXIT\n";
cout<<"\n\t\t\tEnter Option:";
cin>>option;
if(option!='e'&&option!='E')
{
cout<<"\n\t\t\tEnter First Number:";
cin>>num1;
cout<<"\n\t\t\tEnter Second Number:";
cin>num2;
}
if(option!='+'&&option!='-'&&option!='*'&&option!='/'&&option!='R'&&option!='e'&&option!='E')
{
cout<<"\n\t\t\tSELECT the VALID OPTION\n";
}
else if(option=='+');
{
result=addition(num1,num2);
cout<<"\n\t\t\t"<<num1<<" + "<<num2<<"="<<result<<endl;
}
else if(option=='-');
{
result=subtration(num1,num2);
cout<<"\n\t\t\t"<<num1<<" - "<<num2<<"="<<result<<endl;
}
else if(option=='*');
{
result=multipication(num1,num2);
cout<<"\n\t\t\t"<<num1<<" X "<<num2<<"="<<result<<endl;
}
else if(option=='/');
result=division(num1,num2);
cout<<"\n\t\t\t"<<num1<<" / "<<num2<<""<<result<<endl;
}
else if(option=='R')
{
result=remainder(num1,num2);
cout<<"\n\t\t\t"<<num1<<"%"<<num2<<"="<<result<<endl;
}
}while (option!='e'&&option!='E');
cout<<"\n\t\t\tProgram EXIT Successfully.........\n\t\t\t";
return 0;
}
int addition(int num1, int num2)
{
return (num1+num2);
}
int subtraction(int num1, int num2)
{
return (num1-num2);
}
int multiplication(int num1, int num2)
{
return (num1*num2);
}
int remainder(int num1, int num2)
{
return (num1%num2);
}
int division (int num1, int num2)
{
if(num2==0);
{cout<<"\n\t\t\tDivide by ZERO not allowed:"<<endl;
return 0;
}
return (num1/num2);
}
}
}
}
}
}
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 1 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY