C/C++ :: Determine Smallest Number Xmin

Jan 21, 2014

In a fashion similar to that in Fig. 3.11(shown below), write a short program to determine the smallest number, xmin, used on the computer you will be employing along with this book. Note that your computer will be unable to reliably distinguish between zero and a quantity that is smaller than this number.

fig311.png

View 2 Replies


ADVERTISEMENT

C++ :: Find Smallest Number In 2D Array

Oct 21, 2014

I need to generate a grid of 10x8 and fill it with random numbers (max 70), then i need to find the smallest number within the random numbers generated and my "findSmallest" function does not seem to work and i do not know how to make it work...

Here my Code:

include <iostream>
using namespace std;
int main() {
int row=0;
int col=0;
int ArrayGrid [9][11];
srand(time(NULL));

[Code] .....

View 4 Replies View Related

C++ :: Finding Smallest Number In Array?

Oct 17, 2014

I was assigned to create a program that has a 10 x 8 two dimensional array and fill it with random numbers in the range 50 to 70 inclusively.( Got That part down). The second part is to make function named findSmallest that will find and print, appropriately labeled, the smallest number in the array.

I cant seem to get it working. The code for finding the smallest give me some weird number

Here my Code:

//Assignment 18 Program 2
#include <iostream>
using namespace std;

[Code].....

View 2 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

C/C++ :: Find Second Smallest Number Out Of 4 Numbers

Oct 23, 2014

I'm trying to find the second smallest number out of 4 numbers. I produced some code that does that but it doesn't work if i have duplicate numbers.

secondSmallest = a;
if(b > secondSmallest) {
secondSmallest = b;
}
if(c < secondSmallest) {

[Code] ....

View 1 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 :: 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++ :: Program To Find Smallest Real Factor Of A Number

Oct 10, 2013

I need codes for a program in C or C++ that will show the real factor (the smallest one, without the number 1) when an integer is given as input.

When the program is started, it will ask to enter a number and press enter. After entering a number, it will first check if it is a prime number or not. If prime, it will notice that it is a prime number, otherwise, it will print the smallest real factor of the given integer.

For example, if 12 is entered, it will print, the smallest real factor for this number is: 2

If 27 is entered, it will print, the smallest real factor for this number is: 3

...and so on

View 12 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/C++ :: Find Smallest Number In Array Filled With Random Numbers

Oct 24, 2014

I need to find the smallest number in my 10x8 arraygrid with random numebr filled in it

Here my Code:

#include <iostream>
using namespace std;
int main() {
int total,average,smallest;
int row=0;
int col=0;

[Code] ....

View 2 Replies View Related

C :: Determine Minimum Number Of Changes That Can Be Made

Mar 7, 2013

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.

View 6 Replies View Related

C :: Determine Number Of Binary Palindromes In Given Range?

Oct 26, 2013

Write a program to determine the number of binary palindromes in a given range [a;b]. A binary palindrome is a number whose binary representation is reading the same in either forward or reverse direction (leading zeros not accounted for). Example: the decimal number 5 (binary 101) is palindromic.

View 2 Replies View Related

C :: Program That Determine Day Number In A Year For A Date?

Oct 21, 2013

Write a program that determines the day number (1 to 366) in a year for a date that is provided as input data. As an example, January 1st, 1994, is day 1. December 31, 1993, is day 365. December 31, 1996 is day 366, since 1996 is a leap year. A year is a leap year if it is divisible by four, except that any year divisible by 100 is a leap year only if it is divisible by 40. Your program should accept the month, day, and year as integers. Include a function leap that returns 1 if called with a leap year, 0 otherwise. Extend the requested solution so that your program continues to prompt the user for new dates until a negative year is entered. This is what I have so far.

Code:
#include <stdio.h>
#include <stdbool.h>
int main(void) {

int d,m,y;
int days=0;
int k;

[Code] .....

I am unsure how to make this a loop so that it keeps asking for dates?

View 9 Replies View Related

C++ :: Program To Determine Number Of Inputted Riders And Closes When Input Is -1?

Jan 16, 2015

I seem to be having a logical error but can not find the sources.

#include <iostream>
using namespace std;
int main() {
int student = 0;
int adult = 0;

[Code] ....

View 1 Replies View Related

C++ :: Determine Number Of Times Change Each Specific Character In String To Make It Palindrome

Feb 19, 2015

I'm trying to determine the number of times I have to change each specific character in a string to make it a palindrome. You can only change a character one at a time from the end.

Example: "abc" -> "abb" -> "aba" should print 2. "aba" will print 0 because it's already a palindrome. "abcd" -> "abcc" -> "abcb" -> "abca" -> "abba" will print 4 because it took 4 changes to make a palindrome.

I'm not too sure how to approach this - I figured out the case where if it's a palindrome (if reversed string is the same) then it'll print out a 0.

int main() {
int number;
cin >> number; //expecting a number for first line user input
for (int i = 0; i < number; i++) {
string str;

[Code] ....

View 1 Replies View Related

C++ :: Read User Input To Determine Different Discounts By Number Of Units Sold - Errors In Program

Jun 23, 2014

it will not run and im not sure why. I have a couple of errors, but I'm not sure why.

Here is my code.

//Reads input from user to determine different discounts by number of units sold

#include <iostream>
#include <string>
using namespace std;

int main() {
//Declaration and Initialization of variables
int quantity;
double discount,price = 99.00,totalCost;

[Code] ....

View 1 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++ :: 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++ :: Find Smallest In Array Of 7 Numbers

Jul 17, 2012

When I run my program it just gives me 'The smallest number is: 2682760' which isn't true obviously.

Code:
#include <iostream>
int main() {
using namespace std;
int x, smallest;
int Array[7] = {7, 5, 10, 13, 3, 15, 54};
x = Array[0];

[Code] .....

View 3 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++ :: Finding Second Smallest Element In Unsorted Array

May 5, 2013

How should I go about finding the 2nd, or 3rd smallest element in an array? Where the minimum is not equals to the next minimum.

Here is the psuedocode I've found

void Min(A[i..j], int&min, int &next_min)
if (i=j) then min=A[i] and next_min = infinity
else
mid = (i+j)/2
Min(A[i to mid]),a,b)
Min(A[mid+1 to j],c,d)

Let min be minimum among a,b,c,d

Let next_min be the next_min among a,b,c,d

min != next_min

Here is what I wrote but it does not seem to work.

#include<iostream>
#include<vector>
#include <cstdlib>
using namespace std;
void minfind(vector<int> &array,int left,int right, int &min, int &next_min);

[Code]...

View 5 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







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