C++ :: Finding Maximum And Minimum Values Of 10 Numbers Using For Loop
Jan 22, 2013
I want to finding maximum and minimum values of 10 numbers using for loop and the program work wrong !!
#include <iostream>
using namespace std;
int main() {
int x;
int max = -999999999;
int min= 999999999;
[Code] ....
View 2 Replies
ADVERTISEMENT
Oct 29, 2014
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.
View 4 Replies
View Related
Dec 6, 2013
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.
Here's the code:
#include <iostream.h>
#include <conio.h>
#inlcude <math.h>
#include <windows.h>
[Code].....
I know the problem is the "sdt::cin" but I don't know what else to do
View 1 Replies
View Related
Oct 25, 2014
The question is: Write a program that reads 3 integer numbers, then finds and prints the: Mean - Maximum & Second Minimum.
#include <iostream>
using namespace std;
int main () {
double a, b, c;
cout<< "Please enter three values"<<endl;
[Code] .....
View 6 Replies
View Related
Sep 17, 2014
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;
[Code]....
View 7 Replies
View Related
Jan 4, 2015
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
[code]....
View 6 Replies
View Related
Sep 29, 2013
Program that reads 10 students marks and display the average, the maximum and the minimum marks.
Code] ....
#include <Stdio.h>
main(){
// Local Declarations
int marks[10];
int i; /*loop counter */
int avg;
int sum = 0;
[Code] ....
In this program i am able to get Average Marks and Minimum Marks But i am not able to get the Maximum Marks Output correct.
View 6 Replies
View Related
Dec 31, 2014
I am given two month's data (Max, Min, Ave) for every day in that month.
The task is to display all 3 of that data for any selected day in that 2 months.
View 3 Replies
View Related
Nov 3, 2013
i have to make a score average, minimum, maximum as statistics for the out file. here is the code i have done:
Code: #include "stdafx.h"
#include <iostream>
#include <string>
#include <fstream>
[Code].....
View 1 Replies
View Related
Aug 26, 2014
Keep track of the sum of values entered (as well as the smallest and the largest) and the number of values entered. When the loop ends, print the smallest, the largest, the number of values,and the sum of values. Note that to keep the sum, you have to decide on a unit to use for that sum; use cm.
View 9 Replies
View Related
Sep 9, 2013
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];
[Code] ....
View 5 Replies
View Related
Mar 30, 2014
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];
[Code] .....
View 4 Replies
View Related
Jul 26, 2014
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?
View 1 Replies
View Related
Nov 12, 2014
This is part of my main code that is giving me compiler issues.
//Find max value
max = max_element(vecTemperature.begin(), vecTemperature.end());
I keep getting an error saying "[Error] cannot convert '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'int' in assignment"
View 2 Replies
View Related
May 8, 2014
What is the syntax to find the maximum of a function over the interval a≤x≤b starting at a with a step size of Δx ?
View 1 Replies
View Related
Mar 20, 2013
I need to create a loop to return a minimum value using a boolean variable but don't quite understand how to format my algorithm.
#include <iostream>
using namespace std;
int main() {
bool first = true;
while (first) {
cout << "Enter a number (X to exit): ";
int num;
[Code]....
I know its jacked up any comments in the code would be great I need to finish the program but also understand it.
View 6 Replies
View Related
Aug 27, 2014
#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.
View 1 Replies
View Related
Jan 25, 2014
I'm new to C++ and I'm trying to solve the question but there is just something wrong somewhere.
#include <iostream>
using namespace std;
int main() {
int largest;
int a;
int b;
int c;
cout<< "Enter first value";
[Code] ....
View 1 Replies
View Related
Nov 17, 2014
I have come across a problem lately. You are given a set of n sets with m variables.. for instance {a,b,c,d}, {b,c,d}, {b,c}, {c,e,f}, {e,f}. And you want to eliminate elements from these sets with the restriction that you can only eliminate one item from each set and each item can only be eliminated from one set (i.e. if you've eliminated b from set {a,b,c,d}, then you cannot eliminate it from {b,c,d}). The problem is writing an algorithm which determines the maximum number of elements you can eliminate. And I'm hopelessly stuck... of course, you could backtrack it and determine this number but I feel it could be done more efficiently..
View 2 Replies
View Related
Aug 5, 2014
user enter four number and the output will be the greatestt number among these
View 1 Replies
View Related
Jun 20, 2013
User enters sentence "The Smiths have two daughters, three sons, two cats and one dog." (The numbers may change depending on what the user chooses to enter. He told us the range would be from zero to nine.) and we have to convert the written numbers within the sentence into actual decimal numbers and print out the new sentence. Ex. The Smiths have 2 daughters, 3 sons...etc.
I have written the following bit of code which reads the string and finds all the "written numbers" but I am not sure how to proceed from there. I am stuck on how to print out the new sentence with the converted numbers as my professor mentioned something about creating the new string using dynamic memory allocation.
Code:
#include <stdio.h>#include <string.h>
int main () {
char A[100];
int length = 0;
int i;
[Code] .....
View 7 Replies
View Related
Jan 26, 2013
i am trying to find the max value from a list of 10 values. here i have stored the double values for prices of items in numVal.There are 10 values in numVal i would like to find the max and min value of these numbers. getPrice(1) returns the ten double values.
for(int i = 0; i < store.size(); i++) {
double numVal = this->store[i].getPrice(1);
}
View 2 Replies
View Related
Feb 3, 2015
How i can find two equal int in array with O(n) time complexityand O(1) place complexity?
View 8 Replies
View Related
Feb 10, 2014
I need to calculate the expected time it takes to do an activity using a formula provided and after the loop is broken it needs to show the number of projects processed and the project with the longest expected time. I've got everything working except for finding the the project with the longest expected time. What I have here just keeps displaying the number of the last project processed regardless of if it was the largest or not, specifically lines 54-61 is what i can't seem to figure out.
#include <stdio.h>
int main( void ) {
unsigned int counter;
int projectnumber;
int optimistictime;
int realistictime;
[Code] .....
View 1 Replies
View Related
Feb 9, 2013
I'm trying to write a program that will allow a user to enter infinite numbers (one at a time) with a way to stop entering values, and once it stops it immediately displays:
Lowest number:
Highest number:
Number of values entered:
Average of numbers:
what I can't figure out is:
-how to end the loop with something other than a number, preferably a char, so that it doesn't affect the average/lowest/highest
-how to output the lowest and highest numbers in a loop (would be easier to figure out were it finite and I could just type a bunch of printf/scanf)
What I have so far:
Code:
#include <stdio.h>#include <stdlib.h>
#define pause system("pause")
main(){
//n = amount of numbers input
//x = number given by user
//s = smallest number
//l = largest number
}
[code].....
View 4 Replies
View Related
Sep 29, 2014
I've been working at this for awhile and it seems like it should be correct but it isn't giving me the desired output. Here's my code.
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <iomanip>
[Code]....
And here is my output when I run the program.
75
Max: 90
Min: 0
Press any key to continue . . I am reading from a file in this program which contains a set of 30 numbers and it has the average correct and the max correct but the minimum number in the set is 56 however it keeps giving me a zero for the min.
View 4 Replies
View Related