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
ADVERTISEMENT
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
View Related
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
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
Mar 9, 2013
The following fuction from a class is supposed to count the number less then the average of all number combined. but it does not do that, now the fun part if you change it to count the number greater then the average it works great.
void IntegerArray::countBelowAverage() {
avrg=calcAverage(avg);
int count=0;
for(int x=0; x<100; x++) {
if (list[x]<avrg)
[Code]...
How do i get this to post in the proper format?
View 1 Replies
View Related
Oct 15, 2014
I need to create a program that has has an array size of 20 and will generate 20 random numbers in it between 1-1000. Then I need to calculate the average of all the random numbers.
I have half of the code done ,but im lost on how to calculate the average of the random numbers.
Here what I have:
#include <iostream>
using namespace std;
int i;
int size[20];
int counter = 0;
int main() {
cout << "The Array Consists Of 20 Random Numbers: "<<endl<<endl;
[Code] ....
View 2 Replies
View Related
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
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
May 3, 2015
I have a project that I am working on and I have gotten stuck. I am getting a couple errors and would like to see how I can complete the program. Not very long of a program at that. My instructions are:
Write a program to calculate averages. Create a method named ReadData that will load a two dimensional array, named scoresArray, with the following data from a file:
132475.889.392.3
435686.383.498.3
479090.177.376.9
839373.976.389.3
556397.378.478.9
832987.365.377.2
271767.989.379.3
ReadData will have one argument, the scoresArray.
Create a method named DisplayAverages that will display the emplyee number (number starting 1324, 4356 etc) and the average of the three test grades. DisplayAverages will have one argument, the scoresArray. Your output should closely resemble the following.
Student #Test1Test2Test3Average
132475.889.392.385.8
etc, etc
Round averages to one decimal place. Passing arguments is important for this program. No global variables are allowed, except for the streamReader and the streamWriter. The scoresArray must be declared in Main and passed as an argument to the methods ReadData and DisplayAverages.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LibUtil;
using System.IO;
using System.Text.RegularExpressions;
[Code] ....
When I run the following just to see where I am getting I get the following error:
UsersJoeDocumentsVisual Studio 2013ProjectsCIS110Program12Program12Prog
ram12Dat.txt was opened
Unhandled Exception: System.IndexOutOfRangeException: Index was outside the boun
ds of the array.
at Program12.Program.ReadData(Double[,] scoresArray) in c:UsersJoeDocument
sVisual Studio 2013ProjectsCIS110Program12Program12Program.cs:line 66
at Program12.Program.Main() in c:UsersJoeDocumentsVisual Studio 2013Proj
ectsCIS110Program12Program12Program.cs:line 24
Press any key to continue . . .
What am I missing here? I believe I have passed the arguments properly, but I am unable to declair the array within the bounds of the array?
View 2 Replies
View Related
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
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
Apr 21, 2014
Write the function itob(n,s,b) that converts the integer n into a base b character representation in the string s . In particular, itob(n,s,16) formats n as a hexadecimal integer in s .
Note that it says the result is formatted into a hexadecimal integer in the string s. Here is the example provided:
Code:
void itob(int n, char s[], int b) {
static char digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int i, sign;
if ( b < 2 || b > 36 ) {
fprintf(stderr, "EX3_5: Cannot support base %d
[Code] ....
Why does digits array hold the full alphabet when the maximum digit for a hex number is f?
View 1 Replies
View Related
Jan 29, 2014
I was wondering if there was some sort of C++ equivalent for the IDL FIX function. For example, say I want to find all the elements of FLOAT ARRAY1[] that are greater than NUM1 and convert them to INT ARRAY2[].
The problem I have with writing this code myself is not knowing how many elements are going to be greater than NUM1, so I don't know how to initialize ARRAY2[?].
View 1 Replies
View Related
Dec 11, 2013
im trying to write a program that finds the max in an array and divedes it by two than oututs a modfied list with all the elements greater than the max/2.
I got the first part but just not sure how to find the elements greater than the max/2 and output them correctly into the modfied list.
#include <iostream>
#include <iomanip>
using namespace std;
[Code].....
View 2 Replies
View Related
Oct 1, 2014
Where is problem in my code, it is a flappy bird. I dont know why put me that problem when click Start on game show me on 99 line error 'maxValue' must be greater than zero. Parameter name: maxValue
I copy exception to clipboard
System.ArgumentOutOfRangeException was unhandled
HResult=-2146233086
Message='maxValue' must be greater than zero.
Parameter name: maxValue
Source=mscorlib
ParamName=maxValue
StackTrace:
[Code] .....
View 6 Replies
View Related
Feb 17, 2015
I've implemented a records system for a college assignment and everything works as intended. However upon increasing the amount of records to store in my array above 10, the program crashes upon adding a new employee and I can't work out why...
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#define esize 10 /* Change max-records */
[Code] .....
View 3 Replies
View Related
Apr 9, 2014
write a c++ program that reads an unknown number of integer values and then print count, sum and average of odd values, even values, positive values, negative values!!
View 1 Replies
View Related
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
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
Apr 28, 2014
Write a program that uses two functions; one finds the largest number and second largest number; and second function finds the average. The data, comprising of 20 different temperature values, is available on a file.
View 1 Replies
View Related
Feb 6, 2015
#include <iostream>
using namespace std;
int num_ints;
int num_doubles;
double running_total;
double average;
[Code] .....
View 1 Replies
View Related
Mar 20, 2013
Cannot divide the real output of the AVERAGE.:
Code:
#include<stdio.h>
#include<conio.h>
struct student
{
char Name[50];
[Code]....
View 7 Replies
View Related
Nov 29, 2014
How to power value in function too.
View 2 Replies
View Related
Nov 10, 2013
I have to get the average score for each student. And modify my avgmarks function and write the marks to a output txt file.
Code:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int bubble(int*,int);
void filewrite();
void avgmarks();
void fileprint();
void filesort();
void rollin();
[Code] .....
View 1 Replies
View Related
Jan 22, 2013
"Write a program that prompts the user for an integer number from the keyboard, and store it in a variable num. After each number is typed in, add num to a total.
Do this six times, each time adding num to a total. (Be sure to reuse the same variable named num for each of the six numbers entered.) When all six numbers have been entered from the keyboard, calculate an average. Display the total and average calculated. "
Here is what I have so far:
Code:
#include<stdio.h>
int main() {
int num, total1, total2, total3, total4, total5, total6, avg;
printf("Enter first number:");
scanf("%2d",&num);
[Code] .....
View 2 Replies
View Related
May 21, 2013
Howe can i display the average of 100 values in c++ 2008....
View 4 Replies
View Related