In C,Write a function maxmin(float x, float * pmax, float * pmin) where x is a new value which is to be compared with the largest and the smallest values pointed to by pmax and pmin, respectively. The function should indirectly update the largest and the smallest values appropriately. Write a program that reads a sequence of numbers and uses the above function to update the maximum and the minimum until end of file, when the maximum and the minimum should be printed.
PROGRAM:
#include <stdio.h>
#include <stdlib.h>
void maxmin(float x, float * pmax, float * pmin)
{
if(x>*pmax)//comparing x with maximum value if x is greater replacing the max with x
{
*pmax=x;
}
if(x<*pmin)//comparing x with minimum value if x is lesser replacing the min with x
{
*pmin=x;
}
}
int main()
{
FILE* file = fopen ("D:/test.txt", "r"); //reading test.txt file from D: drive
float i = 0;
float max=0.0; //considering max to be 0.0 you can place max to be minimum possible value of float
float min=1000.0; //considering min to be 1000.0 you can place min to be maximum possible value of float
//fscanf (file, "%f", &i);
while (!feof (file)) //traversing through file till end of file
{
fscanf (file, "%f", &i); //scanning every float value from file
maxmin(i, &max, &min); //valling the maxmin function and passing max and min in call by reference way
}
printf("%f\n",max);//printing the maximum value
printf("%f",min);//printing the minimum value
fclose (file);//closing the file
return 0;
}
OUTPUT:

In C,Write a function maxmin(float x, float * pmax, float * pmin) where x is a...
Write a program in C that reads 20 float numbers from a file. The values are stored in a vector (1-dimensional array). Find and display the smallest number, the second smallest number, and the third smallest number of the set. Use only these libraries: stdio.h, stdlib.h, math.h, and string.h. Below is an example of the input file (in1.txt) and the resulting output file (output.txt). In1.txt: 3.14 4.05 -3.73 4.13 1.32 -2.21 0.46 4.57 4.64 -3.42 4.57 -0.14 3.00 -3.58 -0.78...
C language
3. (10 pts) Write a function readSegment that takes three parameters, a float array as a pointer p as the first parameter, and two int indices startldx and endldx. The function readSegment reads the content of the array between startIdx and endldx, without using additional local variables. 4. (10 pts) Write a function called doubleOdds that takes two parameters, an array of double pointed to by pointer p and endldx of int type. The function doubleOdds doubles (multiply...
a) Write a function called print_doubles that prints the first n elements of an array of doubles. Assume the array is long enough. Example: double v[5] = {1,2,3,4,5}; print_doubles(v, 5); // prints [1,2,3,4,5] b) Write a function with the following signature: void get_min_max(const double values[], int n, double *pmin, double *pmax); that returns in output parameters *pmin the value of the minimum element in array values and in *pmax the maximum element. Parameter n represents the size of array values....
Write a program to read the contents of data.txt file, and determine the smallest value (min), largest value (max), and the average value (ave). The minimum, maximum, and average values must be calculated in the function calc(). Remember to declare the stdlib.h library, so that you can use the atof function, which will convert the number in the text file into float number. Also, remember to check if there is an error opening the file or not. If there is...
C++ Manually create a file Numbers.txtand fill it with integers, one below the other. Write a program that reads ANY sequence of integers (can be positive, 0 or negative) from this file. Using a looping construct, you will read numbers from the file till end of the file is reached. Calculate the largest and the smallest numbers among the data in the file. Your code must display both of those on the terminal screen along with total count of numbers...
(a) Find the critical numbers of the function f(x) = x6(x − 1)5. x = (smallest value) x = x = (largest value) (b) What does the Second Derivative Test tell you about the behavior of f at these critical numbers? At x = , the function has a local minimum (c) What does the First Derivative Test tell you that the Second Derivative test does not? (Enter your answers from smallest to largest x value.) At x = ,...
Write a menu based program implementing the following functions: (0) Write a function called displayMenu that does not take any parameters, but returns an integer representing your user's menu choice. Your program's main function should only comprise of the following: a do/while loop with the displayMenu function call inside the loop body switch/case, or if/else if/ ... for handling the calls of the functions based on the menu choice selected in displayMenu. the do/while loop should always continue as long...
using C , comments will be appreciated. Question1 Write down an function named bitwisedFloatCompare(float number1, float number2)that tests whether a floating point number number1is less than, equal to or greater than another floating point number number2, by simply comparing their floating point representations bitwise from left to right, stopping as soon as the first differingbit is encountered. The fact that this can be done easily is the main motivation for biased exponent notation. The function should return 1 if number1...
help me please
Q1 (10 pts) Write a java program that reads and saves 10 values from the user in an array. Then calls function smallestDistance The smallest Distance function will finds two neighboring numbers in an smallest distance to each other. The function should return the index of the first number In the sequence 4 8 6 12 9 4 the minimum distance is 1 (between 1 and 2). The function should return the index 3 (of number 1).
1) Translate the following equation into a Python assignment statement 2) Write Python code that prints PLUS, MINUS, O ZERO, depending on the value stored in a variable named N. 3) What is printed by: 3 - 1 while 5: while 10 Print ) Page 1 of 9 4) Write a Python while loop that reads in integers until the user enters a negative number, then prints the sum of the numbers. 1-2 of 9 4) Write a Python while...