Question

Ask the user to enter the integer radius of a circle, and print out Tr2. Make sure the answer is correct to the area of the cX CODE C + +

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <iostream>
#include <iomanip>
using namespace std; 
int main() { 
   int r;
   double a;
   
   cout<<"Enter Circle Radius(m)\t: ";
   cin>>r;
   
   a = 3.14159*r*r;
   
   cout<<setprecision(2);
   cout<<"Area of circle\t\t: "<<a<<" m^2"<<endl;
   
   return 0; 
}

Output

Enter Circle Radius (m) Area of circle : 1 : 3.1 m^2

Add a comment
Know the answer?
Add Answer to:
X CODE C + + Ask the user to enter the integer radius of a circle,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a Java console application that prompts the user to enter the radius of a circle,...

    Write a Java console application that prompts the user to enter the radius of a circle, then prints its radius, diameter, circumference, and area. Write a JavaFX GUI application to do the same calculation, and draw the circle. The Console Output Enter the radius of the circle: 1.2 The radius is 1.2 The diameter is 2.4 The circumference is 7.5398223686155035 The area is 4.523893421169302 Write and document your program per class coding conventions. Add an instance variable double radius. Generate...

  • JAVA Ask the user for integers. If the user did not enter an integer, ask again....

    JAVA Ask the user for integers. If the user did not enter an integer, ask again. (Type Safe Input) Keep a running total of the intergers entered (sum). Once the user enters 0, stop looping. Print the sum of all the numbers. Do not use try-catch. EXAMPLE OUTPUT: Enter an integer, 0 to stop> [fasdfsa] Invalid input. Enter an integer, 0 to stop> [231.342] Invalid input. Enter an integer, 0 to stop> [1] Enter an integer, 0 to stop> [2]...

  • Write a program that prompts the user to enter a character, an integer, and floating point...

    Write a program that prompts the user to enter a character, an integer, and floating point number. After reading the input, the program should print out the values entered. Be sure to format the code correctly and include relevant comments. in c

  • Write a shell script that given a radius, calculates the area of a circle. (Hint –...

    Write a shell script that given a radius, calculates the area of a circle. (Hint – don’t write this from scratch. Find another script that reads user input and performs a calculation, then modify it to meet your needs.) Save the script in your home directory with the name circle.sh The formula for calculating the area is: Area=Π*Radius2 You can use 3.14 for Π, and either do Radius*Radius or Radius^2 to get the square of the radius. Use the scale...

  • write the c++ code that keeps prompting (10 times) the user to enter an integer. the...

    write the c++ code that keeps prompting (10 times) the user to enter an integer. the code print out the product of all the the integers.

  • Write a complete C++ program to ask the user to enter 4 integers. The program must...

    Write a complete C++ program to ask the user to enter 4 integers. The program must use a function to find the smallest integer among them and print it on the screen. Typical output screen should be as following: Write a complete C++ program to ask the user to enter 4 integers. The program must use a functionto find the smallest integer among them and print it on the screen. Typical output screen should be as following: Note: the code...

  • Ask the user to enter a message Ask the user how many time they want to...

    Ask the user to enter a message Ask the user how many time they want to print the message Then use "while","do-while" and "for" loop to print the message. Show the number at the beginning of the lines when printing. For example: Enter your message: Welcome to Java How many time you want to print this message: 3 Using "while" loop: 1=> Welcome to Java 2=> Welcome to Java 3=> Welcome to Java Using "do-while" loop: 1=> Welcome to Java...

  • Need some help on this C++ program. Circle - color:String - radius:double +Circle() +Circle(newColor:String, newRadius:double) +setColor(color:String):void...

    Need some help on this C++ program. Circle - color:String - radius:double +Circle() +Circle(newColor:String, newRadius:double) +setColor(color:String):void +setRadius(radius:double):void +getColor():String +getRadius():double +printCircleInfo():void Create the class using three files - a .h, a .cpp and a main.cpp Create a class called Circle as describe below Constructor with no arguments Sets radius to 1 and color to “black” Constructor with arguments Sets the color and radius to the values passed in Get methods (accessors) return the field that the get refers to Set methods...

  • c++ QUESTION 9 Write a code that ask the user for the number n of decimal...

    c++ QUESTION 9 Write a code that ask the user for the number n of decimal to average. Then n times the code the user to enter all numbers that you save or accumulate each time. Finaly print to the console the average of the n values the user entered using the format: cout << " The average of the " << n << " number you entered is: " << averagedValue <<endl;

  • Write a complete C++ program to ask the user to enter 4 integers. The program must...

    Write a complete C++ program to ask the user to enter 4 integers. The program must use a function to find the LARGEST integer among them and print it on the screen. Typical output screen should be as following: Note: the code must contain function to find the LARGEST number. Enter four integers 1 2 4 0 Largest integer is 4

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT