Question

**In C programming, Thank you**

Write a program to compute the area of a circle.

You have to write a complete “C” program that compiles and runs in Codeblocks.

Program requirements:

1. Declare the variables needed: radius (r) and area (yourLastName).

2. Calculate and print the area of each circle.

3. The program MUST prompt the user for a new radius (r) over and over until the user types -1.

5. Use the type double for all decimal numbers.

6. When printing the resulting area of the circle please format the output results with a precision of 2 decimal places.

7. To answer this question please submit the main.c file with your code.

8. Your program must include a variable inside the main using your last name, use this variable to save the final result of each area calculation.

double yourLastName**;** // save the final result
of the calculation

You will need the following information:

For PI use the number: 3.1416

Use the following formula: A = PI * (r^2)

For instance, if r=3 then A = (3.1416)*(3*3) = 28.27

**The following is an example of how your program should
look when you execute it:**

Enter the radius of a circle: 2

The area of the circle is 12.57

Enter the radius of a NEW circle: 3

The area of the circle is 28.27

Enter the radius of a NEW circle: 4

The area of the circle is 50.27

Enter the radius of a NEW circle: -1

Answer #1

- Below is the detailed solution of the problem mentioned above in C with code and output with screenshot
- Please read the comments mentioned in the code for better understanding.
**CODE:**

#include<stdio.h>

#include<stdlib.h>

//driver function

int main(){

//constant value of pi used

double PI=3.1416;

//variable to store final area of the circle

double yourLastName;

//variable to store radius input by the user

double r;

//check variable to check if it is the first time or other than
first as we

//are prompting differently.

int check=0;

//loop until user enters -1

while(1){

//first time prompting

if(check==0){

//input radius

printf("Enter the radius of a circle: ");

scanf("%lf",&r);

check=1;

}

//other than first time prompting

else{

//input radius

printf("Enter the radius of a NEW circle: ");

scanf("%lf",&r);

}

//if radius entered is -1 then break from loop

if(r==-1){

break;

}

//otherwise calculate the area of the circle

yourLastName= PI*(r*r);

//and print it on the screen.

printf("The area of the circle is %0.2lf\n",yourLastName);

}

//return from main()

return 0;

}

**INPUT/OUTPUT:**

Enter the radius of a circle: 2

The area of the circle is 12.57

Enter the radius of a NEW circle: 3

The area of the circle is 28.27

Enter the radius of a NEW circle: 4

The area of the circle is 50.27

Enter the radius of a NEW circle: -1

- For better clarity below are the screenshot of the code and it's output attached.

**CODE**

**INPUT/OUTPUT:**

So if you have any doubt regarding this solution please feel
free to ask it in the comment section and if it is helpful then
please upvote this solution, **THANK YOU.**

Write a Python program to calculate the area of a circle. The
user needs to input the value of the radius of the circle.
area = 3.14 x radius x radius
You should use a function named circlearea to perform the
calculation
3.
Write a Python program to calculate the area of a square. The
user needs to input the value of the length of the square.
area = len*len
You should use a function named squarearea to perform the...

Listing 1 shows ABCD.cpp program to compute diameter,
circumference and area for a circle with r, radius without
user-defined function. Listing 2 shows the expected output of
ABCD.cpp on the screen after creating user-defined functions for 3
circles of radius. Write a complete code to compute an output of 3
circles with r, radius as shown in Listing 2. Your answer should
have four (4) functions as stated below as function
declaration.
double displayRadius(double);
double displayDiameter(double);
double displayCircumference(double);
double displayArea(double);

Please use Python programming language to write a client program
and a server program, so that these two programs communicate
through a TCP connection based on the following scenario:
Both of the client program and the server program are running
on the same localhost.
The client program prompts the user to enter the radius of a
circle and pass it to the server program.
The server program computes the area of this circle and passes
it to the client program....

Write a C# source code. Write a function called CircArea() that
finds the area of a circle. It should take an argument of type
double and return an argument of the same type. Write a Main()
method that gets a radius value from the user, calls CircArea(),
and displays the result.

Create a flowgorithm program to calculate the Area of Circle
first then do the Circumference of Circle. The user will have the
ability to convert Area OR the Circumference. That
means we need to add a decision structure to the program.
Furthermore, they need to be able to do it as many times as they
want. That means we need to add a main loop structure to the
program. The user will also have the choice of whether to run...

in c++
Write a C++ program that asks the user to enter an integer
number and prints it back "vertically" to the screen. Use recursion
in your solution. As an example of how the program will work:
Please enter an integer: 12345
The integer you entered will print vertically as:
1
2
3
4
5

Question 1
Write a program that reads from the user the height and radius of a
cylinder, and then outputs the area of this cylinder. The area of
the cylinder is calculated using the formula:
A=2*π*r*h+2*π*r2, where π = 3.14.
Sample run:
Enter the radius of the cylinder: 8.2
Enter the height of the cylinder: 9
The area of the cylinder is 885.75
Question 2
Write a program that reads the name, weight and height of a
patient. Then the...

1) Write a java programming using a while
loop where you will add numbers and when you
press number 0 it will add all your
numbers and display the results.
Use Scanner object.
Steps:
1) Declare variables integer called sum which is equal to
zero
2) Declare Scanner object
3) Declare while condition where is true
4) Inside of that condition prompt the user to enter
the numbers
5) Declare variable integer called number and input
the number statement
6)...

# given a radius, find the area of a circle
def get_area_circle(r):
"""
what it takes
radius of a circle (any positive real number)
what it does:
computes the area of a circle
given a radius, find the area of a circle
area = pi*r2 (pi times r squared)
what it returns
area of a circle. Any positive real number (float)
"""
# your code goes in...

A) write a program the computes nx and store the
result into y
You can use y = Math.pow( Mantissa, exponent)
Requirements:
Besides main() your program must have one method with two
parameters, one double and one int
n and x are positive numbers read from the keyboard
if the user makes an entry that does not meet this criteria, the
user must be given to opportunity retry the entry
the user must be able to quit prior to entering...

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 5 minutes ago

asked 46 minutes ago

asked 59 minutes ago

asked 59 minutes ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago