1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
geniusboy [140]
3 years ago
8

Write a program to calculate surface area and volume of a sphere (ball). The program will ask user to input radius (meter(s)) of

a sphere and return its area and volume (output should round to three decimal places). Use macro #define for value of π (suppose π = 3.1415927). Learn to use pow function for evaluating square and cubic in math.h of C programming library (Google ""pow c programming""). You can use scanf function and double type for radius input. Name your program file Hw2 Q1 Code.c.
Computers and Technology
1 answer:
oee [108]3 years ago
4 0

Answer:

The following program is to calculate the surface area and volume of a sphere(ball) using macro in c language .

#include <math.h>  //header file for math functions

#define pi 3.1415     //using macro

#include <stdio.h>  //header file for printf() or scanf()

int main()   //main function

{  

   double radius;  //radius is a double type variable

   float surface_area, vol;    //surface_area andvolume is a float type variable

   printf("Enter the radius of the sphere : \n");     //printf() is use to print an output

   scanf("%lf", &radius);   //scanf() is use to take input from the user

   surface_area =  4 * pi * pow(radius,2);

   vol = (4.0/3) * pi * pow(radius,3);

   printf("The Surface area of the sphere is: %.3f", surface_area); // display surface area

   printf("\n Volume of the sphere is : %.3f", vol); // display volume

   return 0;  

}

Output:

Enter radius of the sphere : 4.4

Surface area of sphere is: 243.278

Volume of sphere is : 356.807

Explanation:

Here in this program  we  include the header file math.h and include the macro pi. after that taking the user input in radius and calculating the surface area and volume of sphere and finally display the result.

You might be interested in
Python Write a program that asks the user for an integer and then prints out all its factors.
scoray [572]

Answer:

def display_factors(num):

   for counter in range(1, num+1):

       if num % counter == 0:

           print(counter)

int_num= int(input("Enter a number : "))

print("The factors for {} are : ".format(int_num))

display_factors(int_num)

Explanation:

The function display_factors is used to display all factors of a number entered by a user.

  • In this  for counter in range(1, num+1) the for loop is iterated until counter is greater  to num is false.   Counter variable starts from 1 and ends when it gets greater than the input number.
  • if num % counter == 0: In this statement, each loop  iteration, checks whether a number (num) is exactly divisible by counter. It is the condition for counter to be a factor of num.
  • print(counter) This is used to display factors of an input number
  • int_num= int(input("Enter a number : ")) This statement asks user to enter a number (int_num) which will be an integer.
  • display_factors(int_num) This calls display_factors number to find the factors of an input number.

7 0
4 years ago
What do you call the parts of the motor that do not move?.
olasank [31]

Answer:

The stator..?

Explanation:

Stators are the stationary parts of motors. Dunno if I'm right lol

3 0
3 years ago
The procurement department of an organization helps to program software. <br> A)True<br> B)False
valina [46]
I think it is true absolutely
8 0
3 years ago
Read 2 more answers
Netiquette is the
e-lub [12.9K]

Answer:

C

Correct or acceptable way of communicating

4 0
3 years ago
To accommodate a person using a wheelchair, a space of ____ is needed for passing between furniture pieces or walls. 24" 32" 40"
olga_2 [115]

Answer:

the correct answer is 24"

8 0
4 years ago
Other questions:
  • The World Wide Web is a program that allows you to search for information on the Internet.
    11·1 answer
  • Nadia's productivity at work is being hurt due to the large quantity of unwanted e-mail she receives. What steps can she take to
    8·1 answer
  • Helps locate Web pages
    7·1 answer
  • For your biology class, you will be giving a presentation of the findings of a plant growth experiment. Which application is bes
    7·1 answer
  • PLEASE HELP ME I'M TIMED!!!!!!!!!!!!
    5·1 answer
  • What should be a technicians first step in an A/C system
    15·1 answer
  • Which statements accurately describe the Bookmark feature in the Audio/Video control bar? Check all that apply.
    13·1 answer
  • What is the iterative procedure of recursive and nonrecursive?
    10·1 answer
  • PI
    12·1 answer
  • True or False. The 'C' programming language guarantees that R0 will always contain a zero value on the ATmega328P
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!