A function finds approximate maximum or minimum point of a second degree polynomial function (the point where the derivation will equal to zero ). The input polynomial function will be in the following format:
x2 + bx + c = 0 .
Your C function should take a , b and c as input parameters. Your C function also should take the srch_starting_point and stp_sze from the user. Finally, print the resulting maximum or minimum point (m_x, m_y) and step count (n_step) in your function.
For example, if the input is (a, b, c, srch_starting_point, stp_sze );
1 1 1 -3 1
Output similar to;
Maximum point results ( m_x, m_y, n_step )
-1 1 2
i can find the minimum point at first(Using derivation). After choosing starting point, staating point gets lower step size by step size. I can compare numbers to the minimum number. Afterwards, to find m_y i put m_x in the function. Finally, I put a counter to count steps.
I wrote a program to find the minimum and the maximum values from a vector. It works fine. What I'm trying to do is show the positions of said values and it's not working quite right. When I insert 4 elements: 2 0 1 3 it says:
"The min and max are 0 and 3 The position of the min is: 01 The position of the max is: 03"
What am I doing wrong? Here is the code:
Code:
#include <stdio.h> #include <conio.h> int main() { int A[10], i, j, n, min, max, C[10], k=0, D[10], l=0; printf("Insert no. of elements in vector A
I need to write a program that not only calculates the minimum and maximum, but also calculates the average and the difference between the largest and the smallest.
I am trying to make my program read a bunch of numbers in an array to find its maximum and minimum. the program will ask the user to enter in as much number as possible until they enter a non number/letter. i got my program to find the maximum value but the program couldn't read the minimum value. it always says zero. also everytime i enter the number 0, the program will just finish its loop statement. If i typed in a negative number, it'll read the negative number as its minimum.
Code: #include <stdio.h> int main() { //-------variables------------------ double list[1000]; // can hold 1000 items int i; char letter; int max = list[0]; int min = list[0];
I am having a little trouble finding the minimum value in my two dimensional array. I feel like my code is right, but it could be returning the wrong value. Below is my code, this is just my "minimum" function!
Code: int minimum( int array[][MAX], int size ) { int i,j,min; for( i = 0; i < size; i++ ) { for( j = 0; j < size; i++ ) { if( array[i][j] < min ) { min = array[i][j];
I am trying to solve a MIP problem using C with Cplex linker. I need to find min value of two decision variables, as far as i know, i should write as a constraint because they are decision variables. "if" statement does not work for decision variables. here is some part of my model in C.
Code:
void TSPMIP(int Scenario, int Agency) { int i,j; double tmpDouble;
Suppose that a map is defined thus: map<sttring, int> mymap;
I wanna find k maximum values. Is there a way to find the maximum value in an efficient manner? Or else, How can I sort them and then find the k first elements?
#include <stdio.h> float total, avg, max, min; float judge[4]; int index; int array[4]; int main() { total = 0.0; max = array[0]; min = array[0];
[Code] ....
I dont understand how to make the array when it prints out only print out the final average and the final maximum score with the final minimum score but what its doing at the moment is just giving an average for each individual score taken...
Minimum and maximum scores are displaying 0.0
And it displays these things 4 times in a row i just want it to be displayed once.
I have one code that use MPI broadcast and I want to change it into Asynchronous Point to Point communication. I am newbie in Parallel programming. Looking for implementation of one simple same program in broadcast and P2P ?
The method doesn't work properly, the point of the code is to tell the minimum value in the given matrix "m", it's supposed to take the first value of the matrix store it in min_ and then compare it to every value of the matrix, if the value stored in min_ is bigger than the current value in the loop then it's stored as the new min_ and at the end it's supposed to print that minimum...
Code: #include <stdio.h> #include <stdlib.h> #define SIZE 3 void minimum (int mat[SIZE][SIZE]){ int r,c; int min_; printf("
You are given an integer, perhaps a very long long integer, composed of only the digits 1 and/or 2. You have the ability to change a 1 digit into a 2 and a 2 digit into a 1 and must determine the min. number of changes that you can make resulting in no 2 digits remaining in the number that are in a position(in terms of powers of ten) higher than any 1 digit.
example:
2222212 number of changes:1 1111121 1 2211221 3 1122112 2
no negative numbers.
how to get started. Also I'm not allowed to use anything related to arrays or sorting.
I'm trying to write a code to calculate the minimum number of coins needed to cover a change. It works fine but i want to display a message telling the user to try again if they type something that's not a number or a negative number. But it's not working. When i type a negative number, the program runs normally and displays a negative value of coins instead of showing the message. And when i type something that's not a number, the program just keeps showing a lot of zeros nonstop. And when i try to compile it with 'unsigned float' instead of just 'float' i get errors.
Code:
#include <stdio.h> int main() { unsigned int coins; float change; unsigned int n25, n10, n5, n1; unsigned int r25, r10, r5; }
So I am trying to find the min, max, range, mean, median, and mode. The max number is right but the min isnt. Once that is corrected, i can get range and mean easily. Also, how to get mode and median. I am guessing the values in the arr2 would have to be sorted. This refers to the values in arr2 which are the calculated values in the formula. You can enter -2 and 2 for userMin and userMax.
#include <iostream> #include <iomanip> using namespace std; int main() { cout << fixed << setprecision(1); float userMin;