Test case 1 and test case 2 show incomplete at 50% . What am I doing wrong? Please help. Test 1: input =52 Test 2: input = 75.321

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...
icon
Related questions
Question
Test case 1 and test case 2 show incomplete at 50% . What am I doing wrong? Please help. Test 1: input =52 Test 2: input = 75.321
main.cpp
1 source code:
2 #include <iostream>
4 using namespace std;
6 int main()
7 {
8 double length, radius, area;
9 const double PI = 3.1416;
10
11 cout<<"enter the length of the wire: ";
12 cin>>length;
13
14 radius=length/(2 * PI);
15 area=PI * (radius * radius);
16 cout<<"Radius of the circle: "<<radius<<endl;
17 cout<<"Area of the circle<< "<<area<<endl;
18 return 0;
19
20
21 Output:
22
23 Enter the length of the wire:52
24 Radius of the circle is: 8.276
25 Area of the circle is: 215.177
26
it 0%
FED
Transcribed Image Text:main.cpp 1 source code: 2 #include <iostream> 4 using namespace std; 6 int main() 7 { 8 double length, radius, area; 9 const double PI = 3.1416; 10 11 cout<<"enter the length of the wire: "; 12 cin>>length; 13 14 radius=length/(2 * PI); 15 area=PI * (radius * radius); 16 cout<<"Radius of the circle: "<<radius<<endl; 17 cout<<"Area of the circle<< "<<area<<endl; 18 return 0; 19 20 21 Output: 22 23 Enter the length of the wire:52 24 Radius of the circle is: 8.276 25 Area of the circle is: 215.177 26 it 0% FED
Expert Solution
Step 1

Here the output is not coming as required because of set precision concept.

Generally this can be solved by using scanf and printf instead of cin and cout respectively.

I will give an example and you make the change in your code it will work.

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
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 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)
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
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY