C++ :: Find And Print Average Of Odd Numbers Greater Than 5 And Less Than 100

Nov 5, 2014

I am new to programming in C++, and have got a project on this.

Write a C++ program that accepts three numbers from the user (All are integers):

Such as:

Enter the first mark: 3
Enter the second mark: 25
Enter the third mark: 23

The program should find and print the average of the odd numbers greater than 5 and less than 100.

View 4 Replies


ADVERTISEMENT

C++ ::  How To Obtain Total Of Numbers Greater Than Average Without Using Array

Jul 27, 2014

I am facing a problem which i could not obtain the total numbers which is greater than the average value. For example:

#include <iostream>
using namespace std;
int main (){
int size , count;
double no, max, min ,total, sum , average;

[Code] ....

In this case im able to compute the average of the numbers but when it comes to capture the total of numbers which is greater than the average value, how to compile the code , because the average number is only been compute once all the value capture by the input of user is sum up.

View 19 Replies View Related

C++ :: Getting Number Greater Than Average?

Jul 24, 2014

#include<iostream>
using namespace std;
int main(){
int k,num,sum=0,GreaterNO=0;
double average;

[Code] .....

above is my program, I have received an assignment which the lecturer request us to find a series of k numbers then

-display the average
-display the total of numbers greater than the average

our lecturer request us do in 2 version, one is by using array, one is without using array, I have facing the coding problem when doing the VERSION WITHOUT USING ANY ARRAY to get the display the total numbers greater than the average, is there possible to get it?? because there are only one variable keep on looping, but the average will only get after get all the user input....?

View 8 Replies View Related

C :: Find Average Of Random Numbers

Aug 17, 2013

I have the random values down but when I try to assign randValue to another integer I get an error.I want to make an inner loop where I find 5 random number 50 times and print the average of those numbers.

I know I have the bare bones of the below, but without giving me a huge shove in the right direction can I have a poke? I have been programing for three months now. I have noticed when I do simple fun projects I learn more then what my professor assigned to me. The class is over but I want to keep building.C++ starts in one week...

Code:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define NUMBERS 5

int main(int argc, const char * argv[]) {
float randValue = 0.0;
int i;

[code]....

View 9 Replies View Related

C/C++ :: Receive 20 Numbers Or Less And Find Average?

Apr 27, 2015

I made a program that is suppose to receive 20 numbers or less and find the average, then show all numbers entered but my average does not show. It shows as 0 and a line pops up after every number returned. I am stuck and dont know how to fix the logical errors.

#include <iostream>
#include <cmath>
using namespace std;
int main() {
float num[20];
int amount_num;

[Code] ....

View 3 Replies View Related

C++ :: Read Three Numbers From Keyboard And Find The Average

Jan 17, 2013

1): write program to c++ to read three numbers from keyboard and find the average of the three numbers?

2): write program c++ to read two numbers from keyboard and swap between numbers like x=4; y=6; the result x=6; y=4;?

I think that int can do that job. but im not sure.

3): must be the result of positive example: (x+(-y)=z)?

with abs ?

4): values for each of : X= ;y= ;z= ;

View 7 Replies View Related

C++ :: Pass Array Of Int And Its Size - Print Out Numbers Above Average

Nov 15, 2013

I am attempting to write a program " that has a function that is passed an array of int and its size, and with that it prints out only the numbers that are above average. "

I have included my code so far, but I am only getting one value as output, and that value seems to be completely off. I keep trying, but I am really stuck.

#include <iostream>
using namespace std;
int average(int values[],int size);
int main(){
int size;
int values[] = {1,2,3,4,5,6};

[Code] ....

Added the floats in the average() function. But there is still a value problem.

View 1 Replies View Related

C/C++ :: Find Average Of 10 Numbers Passed To Array Using Function?

Jun 20, 2012

find the average of 10 numbers to an array using function .the array should be controlled by while loop?

#include <iostream.h>
float sum(float x[],int size);
    main() {
   float a[10];
int n=10;

[Code] .....

View 2 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 :: Print Correct Normalized Value / Average And Values Above Average

Nov 14, 2013

I must write a function that has a one dimensional double array and the number of values in the array as its arguments. Normalize the values. I must also print the maximum, minimum, average and numbers of values above the average in the array.

The equation that computes the normalized value from a value x is:

Normalized x= (x-min(array))/(max(array)-min(array))

My code does not print the correct normalized value, average and values above average.

Code:
#include <stdio.h>
int findMax( double array1[], int num_elements) // This function computes the maximum value of the array
{
int i, max=-32000;
for (i=0; i<num_elements; i++)

[Code] .....

View 5 Replies View Related

C++ :: 3 Integer Numbers - Find And Print Mean / Maximum And Second Minimum

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

C :: Find Factorial Of Any Number Greater Than Zero And Use Gosper Formula To Approximate It

Feb 24, 2013

I was given a question in my programming class to create a program to find the factorial of any number greater than zero and to use Gosper's formula to approximate it.

Code:
#include <stdio.h>
#include <math.h>
#define PI 3.14159265
double equation(int n);
int

[Code] ....

View 2 Replies View Related

C++ :: Average Negative / Positive Numbers And Total Average?

Nov 18, 2013

I am trying to average the negative numbers and positive number and of course the total average.

This will read in a list of n values, where n is not known ahead of time. The number of values read into the array will be saved in n.

vector<int> readList() {
std::vector<int> result;
ifstream inFile;
inFile.open("setA.txt");
for (int x; inFile >> x; ) {
result.push_back(x);

[code]....

array is a one-dimensional array of integers and n is the number of elements in that array that contain valid data values. Both of these are input parameters to the function. The function must calculate 1) the average of the n integers in array, storing the result in ave; 2) the average of the positive numbers (> 0), storing the result in avePos, and 3) the average of the negative numbers (< 0), storing the result in aveNeg.

void avgs (std::vector &array, int &ave, int &avePos, int &aveNeg) {
int sum = 0, pos_sum = 0, neg_sum = 0, pos_count = 0, neg_count = 0;
for (auto i : array) {
sum += i;
if (i > 0) { pos_sum += i; ++pos_count; }

[code]....

View 1 Replies View Related

C/C++ :: Selectively Choose Only Numbers Greater Than 1000 In Array?

Aug 4, 2013

I am doing my assignment that will calculate total tax amount per day and per week and finally sum those up.

One of the requirement is to filter out any number in the array that is less than 1000 to be assigned a value of zero instead of the stored value so as not to add it in the calculation. How to fulfill this requirement.

View 2 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/C++ :: How To Find Average With For Loop

Sep 14, 2014

What i need it to do is ask the user for a number of cases. The user will input numbers and the program should add the inputs until zero or a negative number is entered and then out put the average of those inputs. The amount of cases is pretty much how many times an average will be done. so if the amount of cases is 4. and the inputs are 1,3,(1+3/2)0 then it should output 2. and that would be ONE case, next inputs are 5,6,4,0(5+6+4/3) the output is 5 and that is case two. etc.

Here is my code:

#include <iostream>
using namespace std;
double avgVal(int, int);
int main() {
int amountOfCases;
cin >> amountOfCases;
int* numbers = new int[amountOfCases];
int input=0;

[Code] ....

View 2 Replies View Related

C++ :: Calculate Average Of Array And Print Elements

Oct 23, 2013

Use function decomposition.

-To prompt user to enter value and assign it to correct position in array
-calculate the average of an array
-display all element.
-display average.

For some reason, i keep getting error and it doesn't compile. I use Dev-C++

Here is my code:

#include <iostream>
#include <iosmanip>
#include <math.h>
using namespace std;
const int SIZE = 5;
const int LINE = 4;
//function prototypes
void getData(int arr[]);

[Code]...

My error is on line 69. I don't see anything wrong with it.

If i take out setw(3), it doesnt get any error but for some reason it doesnt run. Possible i did something wrong there?

View 2 Replies View Related

C/C++ :: How To Find Average Of Three Groups Of Values

Aug 14, 2014

how to compute the averages for 6 values that have been computed from a for loop,

I mean once the for loop finishes it prints me six different values classified into 3 groups as shown down:

group1 has value1
groupe2 has value2, value3, value3
group3 has value5, value6

I want to find the average for each group.

considering the number of values in each group might change. this is the code for finding the values:

for (int i=0; i<n; i++)
{
if (value < 25)
{

[Code]....

View 5 Replies View Related

C++ :: Find Average / Highest And Lowest Score?

Oct 9, 2014

Create a 1-D Array to hold a set of exam scores:

55 74 93 84 64 72 69 78 87 84 72 33 83 68 62 51 88 90

Write a program to do the following tasks:

1. Display scores in rows of four(4) scores.

2. Calculate average score and display.

3. Find Lowest score and display.

4. Find Highest score and display.

5. Find the deviation of each score, and display the score and its deviation.

6. Find the Standard Deviation and Display

7. How many scores are within One Standard Deviation

So I have the average down, but I am getting stuck at the part of displaying the highest and lowest score. Every time I run the program I get two giant negative numbers for both of them. I put all the scores into a .txt file and I just opened in through the program.

#include "TCHAR.h"
#include <iostream>
#include <fstream>
#include <iomanip>

[Code]....

View 1 Replies View Related

C++ :: Program That Prompts User For 10 Grades And Then Find Average

Feb 24, 2015

I need to write a program that prompts the user for 10 grades and then find the average. I have that part but I need to average to not include -1. How can I tell the program to not calculate -1 into the average.

#include <iostream>
using namespace std;
int main() {
//Declare variables
float grade[10]; // 10 array slots
int count;
float total = 0;
double average;

[code].....

View 1 Replies View Related

C++ :: Dynamic Structures - Find Average Value Of All Elements In Deque

Dec 17, 2013

I have a question. How to find the average value of all the elements in a deque?

View 2 Replies View Related

C++ :: Find Average Of 5 Grades - Lowest Number Dropped

Nov 8, 2014

This is a simple program I am building to find the average of 5 grades where the lowest grade is dropped. I created a function findLowest() which accepts the 5 grades as arguments, finds the lowest grade and returns it as "lowest". I have tried many different way to find the lowest number. Right now, I am working with if...then statements.

#include <iostream>
using namespace std;
void printMessage(); //Prototype for printMessage
void getScore(int&); //Prototype for getScore with reference variable
int findLowest(int,int,int,int,int,int &); //Prototype for findLowest with reference variable

[Code] ....

View 2 Replies View Related

C/C++ :: Find Average Of 20 Students By Using A File And One Dimensional Array

Jan 22, 2015

is this according to it??

#include <iostream>
#include <fstream>
using namespace std;
int main(void){
fstream file("textfile.txt");
int linecount = 0;
int tempArray[100];

[Code] ....

View 1 Replies View Related

C++ :: Count The Numbers Below The Average

Mar 7, 2013

I have loaded and 1d array from a .dat file, calculated the average of all the numbers. Now I need to count every number in the array that is below the average and cout that number. This is the method in the class I have so far:

int IntegerArray::countBelowAverage(int numBelowAvg) {
avg=IntegerArray::getAvg();
for(int ct=0; ct<avg; ++ct) {
numBelowAvg=ct;
}
return numBelowAvg;
}

My output from this is always 0 and I know that there are numbers below the avg.

View 2 Replies View Related

C/C++ :: Get Average Of Numbers In Array

Jul 5, 2014

I was trying to make a program that asks the number of grades, get the grades and then get the average. I know I have to save the grades in an array but i don't know exactly how.

View 12 Replies View Related







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