Question

create C program that: Has a triangle function (which receives and sends no arguments) to: Calculates...

create C program that:

  1. Has a triangle function (which receives and sends no arguments) to:
    1. Calculates the area of ANY* triangle (prompts the user for necessary values.)
    2. Uses integer values and displays them in a field width of 8.
    3. Provides an answer to the user such as follows:
      • The area of the triangle with base 7 and height 8 is 28.
  2. Has a circle function (which receives and sends no arguments) to:
    1. Prompts the user for necessary values.
    2. Accurately calculate the circumference of ANY* circle.
    3. Uses a constant for PI (See textbook for constants)
    4. Displays answer with values left-justified, with field with of 4 and only two decimal values
    5. Displays the answer to the user such as follows:
      • The circumference of the circle with a radius of 6 is 37.7.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

the C program is shown below:

#include <stdio.h>
#define pi 3.14// constant declaration
void triangle()
{
int height,base,area_tri;
printf("enter the value of height and base of triangle");
scanf("%d %d",&height,&base);
area_tri=(base*height)/2;
printf("area of the triangle is %d\n",area_tri);
}
void circle()
{
int radious;
double circumference;
printf("enter the value of radious");
scanf("%d",&radious);
circumference=(float)(2*pi*radious);
printf("the circumference of circle with radious %d is %.2f",radious,circumference);// here %.2F gives us precision ipto 2 decimal places
}
int main()
{
triangle();
circle();
}

Add a comment
Know the answer?
Add Answer to:
create C program that: Has a triangle function (which receives and sends no arguments) to: Calculates...
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
  • Create and call a function Using the Visual Basic Editor: create a VBA procedure named call_function...

    Create and call a function Using the Visual Basic Editor: create a VBA procedure named call_function that does the following: Prompts the user, using two input boxes, for the height and the radius of the base of a cone. Calls a function named cone_volume and passes the two values to it. Receives a value back from the function and displays it in a message to the user. Create a function named cone_volume that does the following: Receives the two values...

  • Using the c++ language 1) Create a function that calculates the area of a circle "circeArea...

    Using the c++ language 1) Create a function that calculates the area of a circle "circeArea ()". The function should take a single float parameter radius and return a float area. 2) Create a function to calculate the area of a rectangle. 3) Creat a function to calculate the area of a triangle when given base and height as parameters provided by the user.

  • Experiment with the arguments in the max() function in the program to determine if the function must have four arguments.

    1.   Experiment with the arguments in the max() function in the program to determine if the function must have four arguments. Provide an example for your answer.2. Write code that prompts the user for a floating point number and prints the smallest integer that is larger than the number the user entered.                           3.         Write the code to print a random number between one and six.     4.         Assume that a user enters any number and that the number is stored in the...

  • Q2) Interface Create a program that calculates the perimeter and the area of any given 2D...

    Q2) Interface Create a program that calculates the perimeter and the area of any given 2D shape. The program should dynamically assign the appropriate calculation for the given shape. The type of shapes are the following: • Quadrilateral 0 Square . Perimeter: 4xL • Area:LXL O Rectangle • Perimeter: 2(L+W) • Area:LxW Circle Circumference: I x Diameter (TT = 3.14) Area: (TT xD')/4 Triangle (assume right triangle) o Perimeter: a+b+c O Area: 0.5 x base x height (hint: the base...

  • C++ programming For this assignment, write a program that will act as a geometry calculator. The...

    C++ programming For this assignment, write a program that will act as a geometry calculator. The program will be menu-driven and should continue to execute as long as the user wants to continue. Basic Program Logic The program should start by displaying a menu similar to the following: Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice(1-3): and get the user's choice as an integer. After the choice...

  • C++ Exercice Topic Cover: Class and main implementation 1. Created the class circle.h file 2. Create...

    C++ Exercice Topic Cover: Class and main implementation 1. Created the class circle.h file 2. Create the Circle. cpp 3. Create the main function and use the class Circle in your program (CircleClass) Create a class called circle in other to performing the calculation of the area, sectional area and circumference of any circle. Write a program to test your class. Circle Use double variables to represent the private data of the class. Provide a constructor that enables an object...

  • A) One of the problems that have been discussed in the class is to write a simple C++ program to ...

    C++ programming question will upvote A) One of the problems that have been discussed in the class is to write a simple C++ program to determine the area and circumference of a circle of a given radius. In this lab you will be rewriting the program again but this time you will be writing some functions to take care of the user input and math. Specifically, your main function should look like the following int main //the radius of the...

  • answer in matlab please Create a separate function file fieldtovar.m that receives a single structure as...

    answer in matlab please Create a separate function file fieldtovar.m that receives a single structure as an input and assigns each of the field values to user-defined variables. The function should work for a structure with any number of fields. Additionally, implement an error check to ensure that the number of user- defined variables (output arguments) is equal to the number of structure fields. Here are two examples of calling the function: » Boeing_747 = struct('Length', 70.6, WingSpan', 64.4, 'Engine',...

  • Please use C++ and output have to look like that Create a menu driven C++ program...

    Please use C++ and output have to look like that Create a menu driven C++ program with functions. There must be four functions, calculating the size of area of circle, rectangle, triangle, and parallelogram. You are required to create those four functions and invoke them from the main program in order to reccive any credit. Please Submit: . A flowchart of your program with equations and expected results. 4 points) 2. Printout of your C++program with a heading comment, also...

  • I wrote a program which computes the area and perimeter of a square, circle, or rectangle. As you will see in my main function, there is a for loop in which the user is supposed to be able repeat the...

    I wrote a program which computes the area and perimeter of a square, circle, or rectangle. As you will see in my main function, there is a for loop in which the user is supposed to be able repeat the program until they enter "q" to quit. However, my program runs through one time, the prompt appears again, but then it terminates before the user is allowed to respond to the prompt again. I'm not able to debug why this...

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