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,...
Write a C++ program that solves a quadratic equation to find its roots. The roots of...
Write a C++ program that solves a quadratic equation to find its roots. The roots of a quadratic equation ax2 + bx + c = 0 (where a is not zero) are given by the formula (–b ± sqrt(b2 – 4ac)) / 2a *Use #include for the use of sqrt. The value of the discriminant (b2 – 4ac) determines the nature of roots. If the value of the discriminant is zero, then the equation has a single real root. If...
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.
Multiples of 2 and 3: write a c++ program Using a while loop, write a program...
Multiples of 2 and 3: write a c++ program Using a while loop, write a program that reads 10 integer numbers. The program shall count how many of them are multiples of 2, how many are multiples of 3, and how many are NOT multiples of either 2 or 3. The output should be similar to the one shown below.
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT