Question

Visual Studio - Printf and Scanf Create a function called area that calculates the area of...

Visual Studio - Printf and Scanf

Create a function called area that calculates the area of a triangle. The function requires 2 parameters/arguments. The variables passed to the function are called base and height. To calculate the area multiply height times the base. In addition to the function add your code to both prompt for the values of area and height and base and then call the area function to display/print the area.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <stdio.h>

double area(double base, double height) {
    return 0.5 * base * height;
}

int main() {
    double base, height;
    printf("Enter base: ");
    scanf("%lf", &base);
    printf("Enter height: ");
    scanf("%lf", &height);
    printf("Area is %lf\n", area(base, height));
    return 0;
}
Add a comment
Know the answer?
Add Answer to:
Visual Studio - Printf and Scanf Create a function called area that calculates the area of...
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
  • This program should be run on Visual Studio. Please use printf and scanf as input and...

    This program should be run on Visual Studio. Please use printf and scanf as input and output. Thank you 6.11 Lab Exercise Ch.6a: Functions: String analyzer Create and debug this program in Visual Studio. Upload your Source.cpp file for testing (1) Prompt the user to enter a string of their choosing. Output the string. (1 pt) Ex: ics Enter a sentence or phrase: The only thing we have to fear is fear itself. You entered: The only thing we have...

  • Use Visual Basic language The function, FindAreaOfTriangle, calculates the area of a triangle given the base...

    Use Visual Basic language The function, FindAreaOfTriangle, calculates the area of a triangle given the base and height. Write code that calls the function with: Base = 8; Height = 16.3 and returns the answer to dblAreaOfTriangle.     Function FindAreaOfTriangle(dblBase As Double, dblHeight As Double) As Double         Dim dblArea As Double         dblArea = (dblBase * dblHeight) / 2         Return dblArea     End Function Display keyboard shortcuts for Rich Content Editor

  • 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.

  • Question 4 Write a program that display the area of a triangle. The program calls the...

    Question 4 Write a program that display the area of a triangle. The program calls the following two functions: .getBaseHeight - This function uses a reference parameter variables to accept a double arguments base and height. This function should ask the user to enter the triangle's buse and height. Input validation: base and height should be positive numbers. calArea - This function should accept the triangle's base and height as arguments and return the triangle's area. The area is calculated...

  • Create a program using Visual Studio 2017 called dataExercise.c that declares the following variables and displays...

    Create a program using Visual Studio 2017 called dataExercise.c that declares the following variables and displays their values: 1. Declare a character variable with value 'a', and display the character using printf with a %c format. Then add a second printf that displays the character with a %d format. 2. Declare a short int variable with a value set to the maximum value of a short int (the maximum value for whatever machine I happen to use to grade your...

  • This program should be run on Visual Studio. Please use printf and scanf as input and output. Tha...

    This program should be run on Visual Studio. Please use printf and scanf as input and output. Thank you 6.12 Lab Exercise Ch.6b: C-string functions Create and debug this program in Visual Studio. Name your code Source.c and upload for testing by zyLabs You will write 2 functions which resemble functions in the cstring library. But they will be your own versions 1. int cstrcat(char dstDchar src) which concatenates the char array srcl to char array dstD, and returns 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...

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

    create C program that: Has a triangle function (which receives and sends no arguments) to: Calculates the area of ANY* triangle (prompts the user for necessary values.) Uses integer values and displays them in a field width of 8. Provides an answer to the user such as follows: The area of the triangle with base 7 and height 8 is 28. Has a circle function (which receives and sends no arguments) to: Prompts the user for necessary values. Accurately calculate...

  • Second time posting please answer this question!!! Thankyou!! Please do it in visual studio C #...

    Second time posting please answer this question!!! Thankyou!! Please do it in visual studio C # and post copy of form.cs and designer.cs. Will give vgood review!!! In this module you learned about Classes and Multiforms. You will be completing one program for this module Write a class named Car that has the following member variables: year -    An int that holds the car’s model year. make - A string object that holds the make of the car. speed -...

  • Problem 1 - Print positive message Create a new project named whatever you want in Visual...

    Problem 1 - Print positive message Create a new project named whatever you want in Visual Studio using the Windows Desktop Wizard or in Xcode. If you're using Visual Studio, add a main.c file to your project; you can use the main.c template I provided on Canvas if you'd like. If you're using Xcode, Xcode automatically generates a main.c file for you. Read in an integer from the user; don't prompt for the user input, because that will confuse the...

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