Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. (a) Write a function, int factorial(int n) , which returns n ! (the factorial of n , i.e. 1 2 3 ... n .)
1.
- (a) Write a function, int factorial(int n), which returns n! (the factorial of n, i.e. 1 2 3 ...n.) (b) Using int factorial(int n) above, write a program to compute
1 + 11! + 12! + ...+ 111! .
2. We want to find one of the roots of a cubic equation given by
|
which is between 0 and 1 by an iterative method. Modify the equation above to
|
Start with an appropriate initial value and do the iteration above until it is convergent. For example,
|
The simplest (minimum) code may look like:
3. A set of 500 float numbers is given below:
{133.077, 353.171, 272.317, 9.84711, 100.156, 468.909, 127.629, 1.25313, 331.166, 12.4806, 47.1308, 459.066, 222.106, 320.366, 447.939, 315.992, 368.533, 488.7, 316.918, 201.467, 61.2842, 356.199, 131.416, 110.222, 428.207, 4.02826, 359.1, 101.375, 329.052, 35.1193, 232.471, 101.122, 497.885, 23.6387, 186.34, 142.056, 276.78, 203.273, 238.401, 326.064, 408.247, 214.573, 421.483, 125.597, 347.963, 358.374, 291.067, 16.3751, 419.756, 355.345, 431.967, 415., 91.7042, 321.226, 200.497, 314.879, 93.8189, 298.587, 15.1569, 173.822, 317.039, 96.3144, 276.756, 347.759, 408.792, 381.742, 355.273, 223.162, 61.8293, 24.3681, 65.2061, 207.787, 142.073, 169.023, 133.239, 292.786, 51.3692, 347.797, 432.742, 477.908, 457.55, 50.2092, 418.585, 305.085, 141.511, 453.895, 142.829, 457.327, 232.719, 73.1532, 287.556, 235.165, 171.89, 49.7851, 223.35, 28.3785, 30.8162, 380.762, 91.111, 235.592, 479.447, 33.9658, 158.369, 257.684, 22.8966, 483.757, 239.784, 452.599, 381.386, 30.8617, 97.9551, 495.273, 149.667, 457.709, 310.399, 261.108, 477.777, 408.923, 88.0496, 233.729, 447.961, 29.1611, 496.939, 498.137, 468.514, 495.195, 339.569, 241.452, 446.617, 12.4387, 100.785, 288.853, 66.2314, 481.577, 3.83027, 293.581, 416.565, 24.8685, 193.431, 33.4731, 438.788, 115.945, 106.381, 299.744, 490.828, 87.784, 109.443, 301.607, 23.314, 92.5887, 269.873, 61.155, 76.6971, 81.15, 170.088, 272.302, 11.4657, 99.5729, 167.258, 478.721, 94.9008, 75.7044, 473.827, 446.248, 156.113, 459.759, 368.445, 147.504, 165.285, 372.975, 260.003, 345.897, 142.971, 281.387, 490.129, 285.742, 67.274, 201.237, 321.041, 14.4398, 56.8083, 102.664, 154.783, 35.7185, 461.908, 27.9593, 180.957, 89.4704, 306.795, 68.1999, 312.511, 441.966, 142.51, 195.225, 53.5086, 97.0697, 499.538, 413.838, 63.3795, 311.328, 433.264, 213.601, 242.338, 297.888, 377.456, 111.938, 88.5552, 263.17, 415.549, 84.9783, 407.599, 174.699, 109.754, 17.7784, 96.0876, 232.733, 467.244, 322.554, 43.579, 136.663, 467.706, 408.716, 480.199, 325.335, 35.4412, 196.114, 238.861, 28.4469, 157.985, 85.1769, 151.306, 265.277, 242.437, 1.19858, 243.707, 91.5778, 133.683, 483.42, 148.619, 358.845, 166.439, 161.866, 106.04, 223.182, 198.733, 253.151, 125.841, 397.846, 164.292, 58.0362, 386.98, 370.4, 7.30672, 472.859, 236.674, 106.122, 264.87, 472.661, 492.967, 15.5447, 132.187, 489.24, 345.348, 156.7, 465.749, 328.374, 240.307, 433.518, 268.016, 76.2234, 115.466, 36.6719, 104.724, 19.1872, 228.486, 166.272, 98.4171, 46.328, 491.812, 61.1499, 333.547, 73.6673, 498.844, 46.6052, 202.36, 84.4268, 154.496, 389.905, 236.611, 256.053, 414.189, 456.387, 468.595, 180.829, 299.723, 420.715, 364.871, 162.642, 72.2363, 255.443, 267.454, 117.314, 80.4245, 195.293, 433.907, 44.6469, 81.58, 149.688, 232.548, 460.22, 427.084, 259.782, 495.937, 205.167, 13.8946, 303.395, 28.3416, 25.3379, 214.172, 382.68, 163.47, 362.696, 142.936, 128.237, 396.016, 246.382, 63.5113, 432.945, 462.109, 202.735, 481.931, 284.257, 230.561, 242.515, 55.8477, 25.4743, 234.624, 38.3473, 42.9531, 222.079, 207.283, 14.0094, 328.781, 339.399, 44.8123, 151.314, 186.845, 212.161, 148.796, 404.932, 124.334, 279.217, 186.688, 203.197, 142.403, 494.96, 456.127, 460.683, 87.5551, 470.486, 222.503, 423.336, 45.602, 249.407, 16.22, 410.326, 216.821, 410.008, 471.408, 260.013, 30.9757, 198.847, 323.611, 355.081, 406.642, 419.63, 137.924, 152.883, 265.239, 424.67, 181.797, 192.2, 178.684, 454.185, 459.295, 268.865, 134.082, 205.778, 444.075, 358.539, 417.261, 295.77, 472.667, 99.5259, 387.285, 97.9232, 150.056, 244.445, 480.643, 178.293, 13.1318, 92.5622, 216.404, 253.623, 331.335, 400.362, 38.7207, 299.438, 372.04, 132.497, 404.639, 94.6604, 427.966, 273.959, 487.378, 298.89, 455.299, 175.433, 101.093, 201.967, 306.243, 430.987, 120.45, 24.6742, 294.111, 339.425, 404.045, 271.051, 462.777, 439.063, 366.325, 471.613, 91.7363, 307.566, 461.686, 377.953, 163.771, 34.6073, 474.307, 80.0622, 208.472, 359.175, 374.214, 378.095, 402.229, 428.187, 254.764, 354.421, 109.117, 89.762, 350.719, 84.3694, 146.341, 150.699, 484.394, 112.756, 55.6046, 343.133, 23.7084, 234.804, 391.834, 309.526, 49.4009, 155.742, 184.362, 450.351, 175.187, 277.647, 282.133, 23.1639, 420.422, 423.226, 174.016, 433.402, 70.7036, 339.857, 28.6748, 283.703, 86.3095, 228.1, 473.07, 440.57, 63.6011, 493.296, 82.2363, 132.045, 15.2001, 338.555, 397.874, 181.694, 340.013, 61.9079, 116.741, 159.53, 419.591, 138.682, 442.725, 226.128, 349.887, 298.825};
Write a C program to show how many out of 500 are between 150.0 and 200.0.4. Experimental data are collected as:
x[100]={1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100};
y[100]={-92.3973,14.0677,98.9626,49.6151,111.88,-38.7967,52.1535,-101.325,65.6111,125.129,151.762, -123.132,-41.8744,-39.3356,-99.7856,-128.881,58.5477,-111.692,-75.3057,4.4723,-100.051,169.051, -15.6953,58.3125,147.346,10.9835,42.3421,166.697,-105.534,-90.2199,151.189,130.022,-8.1448,-51.3493, 164.427,119.154,-99.2704,155.986,133.212,118.035,13.1819,139.678,81.5178,-12.4377,-11.7671,146.627, -25.787,107.25,19.8867,15.6437,112.871,122.552,8.42037,-10.1364,146.682,178.531,203.565,-70.7871, 171.256,-50.6232,193.836,-34.7733,-68.9564,25.3423,75.6537,21.5484,46.5259,-64.22,-13.5792, 74.9213,-26.6872,30.5302,169.534,-36.7224,65.4419,113.978,68.1137,181.414,127.76,145.447,75.5486, 164.201,169.504,110.07,96.713,114.974,155.46,2.72803,-59.9407,13.426,29.9344,-11.052,176.639, 162.505,-18.3784,184.418,234.104,127.227,145.18,0.440172};
Obtain the regression line in the form of y = a x + b.
#include
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started