<< Chapter < Page Chapter >> Page >

1) Here is a challenging problem for those who know a little calculus. The Newton-Raphson method can be used to find the roots of any equation y(x) = 0.

Newton-Raphson method
  1. Using the Newton-Raphson method, find the two roots of the equation 3x^2 + 2x –2 = 0. (Hint: Stop the loop when the difference between the two approximations is less than 0.00001.)
  2. Extend the program written for a) so that it finds the roots of any function y(x) = 0, when the function for y(x) and the derivative of y(x) are placed in the code.

2) a. See the definition of determinant of a matrix as below.

Determinant of matrix

Using this information, write and test two functions, named det2() and det3(). The det2() function should accept the four coefficients of a 2 X 2 matrix and return its determinant. The det3() function should accept the nine coefficients of a 3 X 3 matrix and return its determinant by calling det2() to calculate the required 2 X 2 determinants.

b. Write and run a C++ program that accepts the nine coefficients of a 3 X 3 matrix in one main() function, passes these coefficients to det3() to calculate its determinant and then displays the calculated determinant.

3) Your professor has asked you to write a C++ program that can be used to determine grades at the end of the semester. For each student, who is identified by an integer number between 1 and 60, four examination grades must be kept. Additionally, two final grade averages must be computed. The first grade average is simply the average of all four grades. The second grade average is computed by weighting the four grades as follows: the first grade gets a weight of 0.2, the second grade gets a weight of 0.3,the third grade a weight of 0.3 and the fourth grade a weight of 0.2; that is, the final grade is computed as:

0.2* grade1 + 0.3*grade2 + 0.3*grade3 + 0.2*grade4

Using this information, you are to construct a 60 X 6 two-dimensional array, in which the the first four columns for the grades, and the last two columns for the computed final grades. The output of the program should be a display of the data in the completed array.

For test purposes, the professor has provided the following data:

Test data

4) A magic square is an n X n matrix in which each of the integer values from 1 to n*n appears exactly once and all column sums, row sums and diagonal sums are equal. For example, the following is a 3 X 3 magic square in which each row, each column, and each diagonal adds up to 15.

Magic matrix
  1. Write a function that accepts a two-dimensional array and integer n and checks if the n X n matrix stored in the array is a magic square. The function should return true if it is a magic square and false if it isn’t. And also design it to return the “magic sum” of the magic square (sum of each row = sum of each column = sum of each diagonal).
  2. Write the driver program that:
    • Let you enter the elements of a matrix.
    • Calls a matrix-printer function to display it.
    • Calls your magic-square-checker function to check if it is a magic square and displays an appropriate message (including the magic sum if it is a magic square.)

Questions & Answers

A golfer on a fairway is 70 m away from the green, which sits below the level of the fairway by 20 m. If the golfer hits the ball at an angle of 40° with an initial speed of 20 m/s, how close to the green does she come?
Aislinn Reply
cm
tijani
what is titration
John Reply
what is physics
Siyaka Reply
A mouse of mass 200 g falls 100 m down a vertical mine shaft and lands at the bottom with a speed of 8.0 m/s. During its fall, how much work is done on the mouse by air resistance
Jude Reply
Can you compute that for me. Ty
Jude
what is the dimension formula of energy?
David Reply
what is viscosity?
David
what is inorganic
emma Reply
what is chemistry
Youesf Reply
what is inorganic
emma
Chemistry is a branch of science that deals with the study of matter,it composition,it structure and the changes it undergoes
Adjei
please, I'm a physics student and I need help in physics
Adjanou
chemistry could also be understood like the sexual attraction/repulsion of the male and female elements. the reaction varies depending on the energy differences of each given gender. + masculine -female.
Pedro
A ball is thrown straight up.it passes a 2.0m high window 7.50 m off the ground on it path up and takes 1.30 s to go past the window.what was the ball initial velocity
Krampah Reply
2. A sled plus passenger with total mass 50 kg is pulled 20 m across the snow (0.20) at constant velocity by a force directed 25° above the horizontal. Calculate (a) the work of the applied force, (b) the work of friction, and (c) the total work.
Sahid Reply
you have been hired as an espert witness in a court case involving an automobile accident. the accident involved car A of mass 1500kg which crashed into stationary car B of mass 1100kg. the driver of car A applied his brakes 15 m before he skidded and crashed into car B. after the collision, car A s
Samuel Reply
can someone explain to me, an ignorant high school student, why the trend of the graph doesn't follow the fact that the higher frequency a sound wave is, the more power it is, hence, making me think the phons output would follow this general trend?
Joseph Reply
Nevermind i just realied that the graph is the phons output for a person with normal hearing and not just the phons output of the sound waves power, I should read the entire thing next time
Joseph
Follow up question, does anyone know where I can find a graph that accuretly depicts the actual relative "power" output of sound over its frequency instead of just humans hearing
Joseph
"Generation of electrical energy from sound energy | IEEE Conference Publication | IEEE Xplore" ***ieeexplore.ieee.org/document/7150687?reload=true
Ryan
what's motion
Maurice Reply
what are the types of wave
Maurice
answer
Magreth
progressive wave
Magreth
hello friend how are you
Muhammad Reply
fine, how about you?
Mohammed
hi
Mujahid
A string is 3.00 m long with a mass of 5.00 g. The string is held taut with a tension of 500.00 N applied to the string. A pulse is sent down the string. How long does it take the pulse to travel the 3.00 m of the string?
yasuo Reply
Who can show me the full solution in this problem?
Reofrir Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Programming fundamentals in c++. OpenStax CNX. Jul 29, 2009 Download for free at http://cnx.org/content/col10788/1.1
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Programming fundamentals in c++' conversation and receive update notifications?

Ask