#include #include #include double area (double r); // this starts the definition for the area function using namespace std; int main() { double r1, r2, carea1, carea2; // vartable definitions cout<«" Please input the radius of a circle (can be decimal): cin>> r1; carea1=area(r1); // this is the first function call cout<« " The area of the first circle is: " « carea1 <> r2; carea2= area(r2); // this is the second function call Cout<<" The area of the second circle is: " << carea2 <« endl; return 0;

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

What is wrong with the following code? the end goal is to run the program and to be able to find the area of two circles. However, when running the program I encounter an error. The language being used is C++

1- /****
************** *****************************
2
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
3
4
7
オ
8.
#include <iostream>
9.
#include <cmath>
#include <cstdlib>
10
11
12 double area (double r); // this starts the definition for the area function
using namespace std;
14
13
int main()
16 - {
15
double r1, r2, carea1, carea2; // variable definitions
cout<<" Please input the radius of a circle (can be decimal):
cin>> r1;
carea1-area(r1); // this is the first function call
cout<<
17
18
19
20
21
The area of the first circle is: " « carea1 <<endl;
22
cout<<" Please input the radius of a second circle (can be decimal): ";
cin>> r2;
carea2= area(r2); // this is the second function call
Cout<<" The area of the second circle is: " « carea2 <« endl;
23
24
25
26
27
28
гeturn 0;
29 }
30 - double area (double r) {
if (r>=0)
return(3.14159)*(pow(r,2));
else
31
32
33
34
return (3.14159)*(pow(abs(r,2));
35 }|
mmmm mm
Transcribed Image Text:1- /**** ************** ***************************** 2 Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. 3 4 7 オ 8. #include <iostream> 9. #include <cmath> #include <cstdlib> 10 11 12 double area (double r); // this starts the definition for the area function using namespace std; 14 13 int main() 16 - { 15 double r1, r2, carea1, carea2; // variable definitions cout<<" Please input the radius of a circle (can be decimal): cin>> r1; carea1-area(r1); // this is the first function call cout<< 17 18 19 20 21 The area of the first circle is: " « carea1 <<endl; 22 cout<<" Please input the radius of a second circle (can be decimal): "; cin>> r2; carea2= area(r2); // this is the second function call Cout<<" The area of the second circle is: " « carea2 <« endl; 23 24 25 26 27 28 гeturn 0; 29 } 30 - double area (double r) { if (r>=0) return(3.14159)*(pow(r,2)); else 31 32 33 34 return (3.14159)*(pow(abs(r,2)); 35 }| mmmm mm
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education