C++ :: Input Three Integers From Keyboard - Print Smallest And Largest Numbers

Nov 18, 2013

I am trying to Write a program that inputs three integers from the keyboard and prints the sum, average, product, smallest and largest of these numbers. How do i go about it. What i dont know is how to come up with smallest and largest number .

View 1 Replies


ADVERTISEMENT

C++ :: For Loop - Display Smallest And Largest Numbers From User Input

Jul 29, 2013

I'm suppose to write a program using (for loop) that asks the user to enter any amount of numbers, so that it can display the smallest and largest. My program successfully finds the largest, but it is always displaying 0 for the smallest, I think Im doing something wrong with the internalization but I dont know what to change it to.

This is what I have ....

#include <iostream>
using namespace std;
int main() {
int amount;
int count;
int number = 0;
int smallest = 0;
int largest = 0;
cout << "Enter total numbers to process: ";

[Code] ....

View 4 Replies View Related

C/C++ :: Cannot Get Largest And Smallest Numbers Using Functions

Feb 6, 2015

#include<iostream>
using namespace std;
int computeTotal();
int findSmallest();
int findLargest();

[Code] .....

View 4 Replies View Related

C# :: Getting Largest And Smallest Values From Random Numbers?

Dec 2, 2014

The only part I have working is getting all odd random numbers but the logic in getting the largest and smallest from random is what is giving me alot of trouble.

class Program {
static void Main(string[] args){
int num = 0;
int largest = 0;
Random rand = new Random();
for (int ctr = 1; ctr <= 100; ctr++)

[code]....

Console.Write("{0,5} The larget number out of 100 odd numbers is: {1:n}",y,largest);

View 4 Replies View Related

C/C++ :: Sorting Numbers In Array From Largest To Smallest?

Mar 16, 2014

I'm trying to sort the numbers in an array from largest to smallest and print it but whenever I run this it does not sort anything at all.

#include <stdio.h>
#define SIZE 10
void Input(const int array1[]);
void Calculations(int array1[], int average);
void Output(int array1[], int average);
size_t counter1 = 0;
int average;
int main( void ) {
int array1[ SIZE ];

[code]....

View 4 Replies View Related

C :: Find Smallest / Largest And Average Values In A Collection Of N Numbers

May 30, 2014

I seem to have reached a dead end in a program I am attempting to write.The purpose of the program is find the smallest, largest, and average values in a collection of N numbers. It needs to get the value of N before scanning each value in the collection of N numbers.I'm having trouble creating comparisons for each set. I have a feeling because of the way I structured my program, I'm unable to make a proper comparison. Maybe my approach was wrong as soon as I got to the for statement to loop N sets and N numbers.Here is my code so far:

Code:

#include <stdio.h>
int main (void)
{
int num_sets, num_of_integers;
int count, count2, set, sum = 0;
int num, avg;
}

[code]....

/* Here is where I would continue to attempt to make a comparison between sets to determine smallest to largest */

return 0;

View 5 Replies View Related

C++ :: Write A Source Code That Find Smallest / Largest And Average Of Numbers From Array

May 13, 2014

im trying to write a source code that find the smallest, largest and average of numbers in array. the code runs fine, but it is not giving the highest number and the the average should include only four number excluding highest and smallest number from the array.

void OlympicJudging() // Olympic Judging {
int numbers [6];
double average, sum = 0;
int temp;
for(int i = 0; i < 6; i++){
cout << "Please type a value for scores: ";
cin >> numbers[i];

[Code]...

View 5 Replies View Related

C++ :: To Mark Both Smallest And Largest Element

Mar 13, 2013

This code, asking to mark both the smallest and the largest element. I just got largest, didn't get smallest number. Here is code:

#include <iostream>
using namespace std;
int main() {
const int CAPACITY = 1000;
double values[CAPACITY];
int current_size = 0;

[Code] .....

View 9 Replies View Related

C/C++ :: Ordering Array From Largest To Smallest?

May 25, 2014

Write a program that reads in a list of integers into an array with base type of int. Provide the facility to either read this array from the keyboard or from a file, at the user's option. If the user chooses file input the program should request a file name. You may assume that there are fewer than 50 entries in the array. Your program determines how many entries there are. The output is to be a two-column list. The first column is a list of the distinct array elements; the second column is the count of the number of occurrences of each element. The list should be sorted on entries in the first column, largest to smallest.

For example, for the input
-12 3 -12 4 1 1 -12 1 -1 1 2 3 4 2 3 -12

the output should be
N Count
4 2
3 3
2 2
1 4
-1 1
-12 4

Here's My code So far:

#include <iostream>
#include <fstream>
using namespace std;
const int SIZE = 50;

[Code]....

My Code outputs the numbers From Largest to Smallest according to given array, but I need to make it to output the numbers once(if its repeated)

View 2 Replies View Related

C/C++ :: How To Find Smallest And Largest Number

Oct 18, 2014

Write a program that will find the smallest, largest and average of the values in a collection of N positive integer numbers.

View 12 Replies View Related

C :: How To Calculate Largest / Smallest / Average - No Array

Feb 16, 2015

i'm having trouble trying to make this code works .. the program must repeatedly asks user for the age of a person until user enters -1 ,, once he/she entered -1 the program calculates ( smallest value entered, largest value , and average )excluding -1 from calculation

i've been working on this for a weeks this is the best i could do.i know average must add all the entered values , not only smallest and largest but how can i do that here ?

Code:

#include<stdio.h>
int main(void)
{
int age ;
int v;
int counter;
int l=0;
int s=0;
int limit;
}

[code]....

View 13 Replies View Related

C :: Finding Largest / Smallest / Average In A Loop

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

C++ :: Display Largest And Smallest Valleys Of Array?

Dec 4, 2013

I am working on a c++ assignment and I need to display the smallest and largest values of an array called from a .txt file...but I don't know how to display them...

This is what I have so far::

#include<iostream>
#include<string>
#include<fstream>
#include<cstdlib>

[Code].....

and the .txt file is:

12 43 11 10 9 54 36 75 96 83 23 35 67 35 47 58 69 13
45 67 89 78 66 44 1 55 59 81 18 0 42 199 4 100 46 76

View 2 Replies View Related

C++ :: Finding The Largest And Smallest Integer In A Set Using While Loop

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

C :: Find The Largest And Smallest Number Entered By User?

Mar 6, 2015

How to find the largest and smallest number entered by a user. So far I'm able to add, find the average and count how many numbers are entered.

I'm just having trouble with find the max and min. I tried if statements and it breaks the program will it wont let me exit the while loop or the program will do a force close after entering a value.

Code:

#include <stdio.h>
#include <stdlib.h>
int main(){

int maxNum=0, minNum=0, value, count=0, sum=0;
double average;

[Code] ....

View 4 Replies View Related

C++ :: Finding Smallest / Largest And Average Number - Do While Loop

Sep 10, 2013

I am stuck looking at whats the problem ....

#include <iostream>
using namespace std;
int main() {
float average, largest = 0, smallest = 0;
int count = 1;
int num;

[Code] .....

View 1 Replies View Related

C++ :: User Defined Functions - Find Largest And Smallest Number

Nov 16, 2013

I am writing this code, and I every time I run question A, no matter what numbers I put in, I get "larger = 0.

#include <iostream>
using namespace std;
int awesome ();
int best ();
int crazy ();
int main () {
char letter;
int smallestNumber;
int largestNumber;

[Code] .....

View 2 Replies View Related

C++ :: Program Read In 15 Integers From User Then Store And Print Out Numbers

Apr 29, 2014

I want to write a program to read in 15 integers from the user, and then store them in a 5x3 array, and print out the numbers as a 3x5 array.

View 7 Replies View Related

C/C++ :: Read Integers Into Array / Sort Numbers And Print Out Occurrence Of Each Number

Apr 6, 2014

My C programming class wants us to write a program to read integers into an array, sort the numbers and print out the occurrence of each number. I've tried everything that I can think of but the core dump is still occurring.

void countValues ( FILE *inf, int list[], int size ); /* Function prototypes. */
void printFrequencies( const int list[], int size );
int main (void) {
int status = EXIT_SUCCESS; /* defaulting status to success. */
FILE *inf = fopen( "numbers.txt", "r" ); /* input data file */

[Code] .....

View 6 Replies View Related

C++ :: User Input 10 Integers Of Array - Add Numbers Greater Or Equal To 10

Oct 29, 2013

create a program that asks the user to input 10 integers of an array the program will add the numbers greater or equal to 10.

View 6 Replies View Related

C++ :: Delete Smallest Part Of List Of Integers To Sort In Non Decreasing Order

Mar 24, 2013

I am supposed to make a program that take a list of integers from the user and to delete the smallest part of it in order to make it sorted in non decreasing order ..

example : input : 1 2 3 4 5 8 7 6 7 8 9
output : 1 2 3 4 5 6 7 8 9 ( delete : 8 7 )

I need a code that use a technique similar to the merge function to achieve linear time ..

this code works but it is in quadratic time :

int main () {
cout<<"Enter a list of numnbers ending with the sentinel -999:"<<endl;
int A[1000];
int n = 0;
int x;
cin>>x;
while(x!=-999)

[Code] ....

View 4 Replies View Related

C/C++ :: Program That Will Print Numbers In Columns From User Input

Oct 7, 2014

I tried to work on this program for while, but I am not able to get it to work

Directions:Write a program that reads an integer n from the user.

Display the first 100 numbers, with newlines every n numbers, using % operator

#include <stdio.h>
int main(void){
int a = 0;
int b = 99;
printf("Enter a number: ");
scanf ("%d", &a);

[Code] ....

When I run this code it asks me to enter a number. It doesn't matter what number I enter it gives me the numbers from 1 to 100 in one horizontal line.

I want this program to do something like this:

for example if the user enters n=6 the program should give:

0 1 2 3 4 5 6
7 8 9 10 11 12 13
and so on

View 2 Replies View Related

C :: Function Call To Print Smallest Number?

Mar 15, 2013

C programming, make it use a function call to print the smallest number? this is a program which prints out the smallest of three numbers within the main function that I was asked to write.Now the other question i am asked,5. Re-write the program, uses a function call to print the smallest number?

Code:

# include <stdio.h>

main()
{
int a,b,c;
int temp, min;
a = 100;
b = 23;
c = 5;
}

[code]....

View 5 Replies View Related

C++ :: Read Set Of Integers Then Find And Print Sum Of Even And Odd Integers

Apr 21, 2014

I'm a beginner at c++ and I need to write a program that reads a set of integers and then finds and prints the sum of the even and odd integers. The program cannot tell the user how many integers to enter. I need to have separate totals for the even and odd numbers. what would I need to use so that I can read whatever number of values the user inputs and get the sum of even and odd?

View 2 Replies View Related

C :: How To Print Largest Number From 5 Rows

Sep 26, 2013

i want to print Largest number from any 5 rows.Th number printed should be any one of the largest in the five rows of 2d arrays.I have created code for largest number in each row but how to pick and print them randomly?.

Code:

#include<conio.h>
main( )
{
int a,b,c,d,e,x;
int arr[] = {a,b,c,d,e};
int Matrix[5][5] ={ /*Initializing array*/
2,4,3,5,9,
6,8,2,2,10,

[Code]...

View 9 Replies View Related

C++ :: How To Find The Smallest Number Amongst 4 Numbers

Nov 28, 2013

How to find the smallest number amongst 4 numbers

View 10 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved