
2. 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,
(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
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};
2. Code :
#include <stdio.h>
int main()
{
int count=0;
float numbers[500];
for(int i=0;i<500;i++)
{
scanf("%f",&numbers[i]);
if(numbers[i]>100.0 &&
numbers[i]<150)
{
count++;
}
}
printf("The no. of elements between 100.0 and 150.0:
%d",count);
return 0;
}
Screenshot of the Code:

OUTPUT:

a) Code:
#include <stdio.h>
int fact(int n);
int fact(int n)
{
if(n==0)
{
return 1;
}
else
{
return n*fact(n-1);
}
}
int main()
{
int num,f;
printf("Enter number: ");
scanf("%d",&num);
f=fact(num);
printf("The factorial of num= %d",f);
return 0;
}
Screenshot and Explanation of Code:

OUTPUT:

2. A set of 500 float numbers is given below: {133.077, 353.171, 272.317, 9.84711, 100.156, 468.909,...
Count Below and Above Average Numbers
Use the following main( ) function:
const int maxSize = 50;
int main()
{
int l, u, n, A[maxSize], le, mo;
input(l, u);
cout << "How many numbers you want to generate < 50:
";
cin >> n;
generateNumbers(n, l, u, A);
le = countLessMore(n, A, mo);
cout << "There are " << le << " numbers less
than the average and "
<< mo << " numbers more than the
average" <<...
Write a program that writes a series of random numbers to a file. Each random number should be in the range of 1 through 500 inclusive. 1.Use a file called randoms.txt as a input file and output file a. If you go to open the file and its not there then ask the user to create the file and then quit 2. Ask the user to specify how many random numbers the file will hold. a.Make sure that the...
DQuestion 19 28 pts Problem 2. Quadratic Equations A quadratic equation has the form: a bc0 The two solutions are given by the formula: 2a Write a program with a loop that a) solves quadratic equations with coefficients read from the terminal, b) visualizes the corresponding quadratic function az2 brc0using the matplotlib module. Instructions Write all code for this problem in a file p2.py 1. The program consists of a main whtle loop (an infinite loop) in which the user...
I ONLY NEED PART 4 I HAVE DONE 1,2,3 Arrays This assignment is designed in small progressive parts, with the intention of developing the skill of working with arrays. Do each part separately. Include in your submission the code and output for Part I, then the code and output for Part 2, etc. into a Word document. Specification: Part 1. Write a main function that declares an array of 10 int’s. Assign each element in the array a value between...
PROJECT TASKS 1. Read the problem definition below and write a C++ program that implements your solution. Readability of the program will be graded based on variable naming, indentation, commenting (not too little and not too much), spacing, consistency, and styling in general including choice of functions. [NOTE: the code at the end of this document does not completely meet requirements as it uses many single letter variables and has no internal documentation. You need to improve it.] 2. Compile...
Program Set 2 10 points) Credit card number validation Program Credit card numbers follow certain patterns: It must have between 13 and 16 digits, and the number must start with: 4 for Visa cards 5 for MasterCard credit cards 37 for American Express cards 6 for Discover cards In 1954, Hans Luhn of IBM proposed an algorithm for validating credit card numbers. The algorithm is useful to determine whether a card number is entered correctly or whether a credit card...
I really need help with this python programming assignment Program Requirements For part 2, i need the following functions • get floats(): It take a single integer argument and returns a list of floats. where it was something like this def get_floats(n): lst = [] for i in range(1,n+1): val = float(input('Enter float '+str(i)+': ')) lst.append(val) return lst • summer(): This non-void function takes a single list argument, and returns the sum of the list. However, it does not use...
For this assignment, write a program that will generate random numbers in the range of 50-100 and count how many fall into particular ranges. Processing: The program should first seed the random number generator. This is done one time in the program. Use srand(0). Next, generate and display a series of 10 random numbers between 50 and 100. There are several ways to ensure that a random number falls between 50 and 100. One possibility is to use the following...
Java Project Name: IC19_WinningTheLottery n this assignment, we're going to attempt to win the lottery! (**If you do actually win the lottery, please be sure to give back to your alma mater, Orange Coast College. We will be happy to put your name on the building!**) Ok, time to get real. The Fantasy 5 (TM) lottery is a game in which 5 numbers from 1 to 36 are randomly drawn by the State of California. If you correctly guess all...
First create the two text file given below. Then complete the
main that is given. There are comments to help you. An output is
also given You can assume that the file has numbers in it
Create this text file: data.txt (remember blank line at end)
Mickey 90
Minnie 85
Goofy 70
Pluto 75
Daisy 63
Donald 80
Create this text file: data0.txt (remember blank line at
end)
PeterPan 18
Wendy 32
Michael 28
John 21
Nana 12
Main
#include...