Question

In: Computer Science

(IN C) Program Question 2: Write a program that solves for c in the Pythagorean Theorem:...

(IN C)

Program Question 2: Write a program that solves for c in the Pythagorean Theorem: a2 + b2 = c2 The user will enter values for a and b, and you will calculate c. All of this code will go in just one source file.

Solutions

Expert Solution

#include <stdio.h>
#include <math.h>

int main(){
   float a, b, c;
   
   printf("Enter value for a: ");
   scanf("%f",&a);
   
   printf("Enter value for b: ");
   scanf("%f",&b);
   
   c = sqrt(a*a+b*b);
   
   printf("c = %f\n",c);
   return 0;  
}

Related Solutions

Write a program in C++ that solves this problem Calculate the area and volume of a...
Write a program in C++ that solves this problem Calculate the area and volume of a sphere problem. Inside a for loop, vary the radius from 10 to 40  with a step or increment of 5 and calculate the area and volume Your radius will be equal to your loop counter. All calculations should have 2 decimal places, but the radius should have zero decimal places and any number of 1,000 or more should have a comma. Print the radius, area,...
1.What is the First Condition of Equilibrium? 2.Explain what Pythagorean Theorem is and give the formula....
1.What is the First Condition of Equilibrium? 2.Explain what Pythagorean Theorem is and give the formula. ? 3.The Scalar Product or otherwise known Dot Product of two vectors is the sum of the products of their respective components. What does the scalar product give us? And when is the product zero?
I. Design the C++ code for a program which will use the Pythagorean Theroem to calculate...
I. Design the C++ code for a program which will use the Pythagorean Theroem to calculate and display the length of a right triangle hypotenuse,c, given the lengths of its adjacent sides: a and b.. (hint: a^2 + b^2 = c^2) II. Design the C++ code for a program which will calculate and display the roots of a quadratic equation of the form ax^2 + bx + c = 0, given its coefficients, a, b, and c.
Question 2. Write a complete C++ program that uses a 2-dimensional array with 4 rows and...
Question 2. Write a complete C++ program that uses a 2-dimensional array with 4 rows and 30 columns. Row represents sections of a course and column represents the students, value inside each position of the array is the final exam grade for each students. Fill the array with random numbers between 40 and 100. Calculate the total, average, maximum, minimum for each section. Please do it simple. code
Write a full program that solves the following equation and displays the value for x and...
Write a full program that solves the following equation and displays the value for x and y: 3.4x+50.2y=44.5 2.1x+.55y=5.9
Create a C program that solves the word search puzzle contained in the file 'WordSearchPuzzle.txt'. The...
Create a C program that solves the word search puzzle contained in the file 'WordSearchPuzzle.txt'. The words that need to be found are in the file 'WordList.txt'. There are 100 words to be found. You must find the location of the first and last letter of each word as well as the cardinal direction that describes the word's orientation. The location of first and last letters are to be described in terms of row and column, with indexing starting at...
Write a program that solves the Knapsack problem. Code to the following standards. Your source of...
Write a program that solves the Knapsack problem. Code to the following standards. Your source of items to put into the knapsack should consist of five randomly generated integers in the range of 1 to 20. Your knapsack can hold 20 lbs.
QUESTION 2 write a c++ program Assume that you own a construction company that builds different...
QUESTION 2 write a c++ program Assume that you own a construction company that builds different types of buildings. The goal is to write a program that is potentially useful for your company. [5 points] Define a base class called building. Include at least two member variables and three member functions [10 points] Define two derived classes that inherit properties from the base class [10 points] Demonstrate at least one example each of overriding and overloading by defining the functions...
I need specific codes for this C program assignment. Thank you! C program question: Write a...
I need specific codes for this C program assignment. Thank you! C program question: Write a small C program connect.c that: 1. Initializes an array id of N elements with the value of the index of the array. 2. Reads from the keyboard or the command line a set of two integer numbers (p and q) until it encounters EOF or CTL - D 3. Given the two numbers, your program should connect them by going through the array and...
C++ Question: write a program that prompts the user for the length and width of a...
C++ Question: write a program that prompts the user for the length and width of a rectangle in inches.  The program then uses functions to compute the perimeter and area of the rectangle and to convert those to meters and square meters respectively. Sample output from one instance of the program is shown below: ```html Welcome to the Foot-To-Meter Rectangle Calculator ================================================= Enter the rectangle length in feet: 2 Enter the rectangle width in feet: 3 The rectangle dimensions are: 0.61...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT