I'm in an engineering class and our teacher taught us ABSOLUTELY NOTHING about writing software. I'm sitting here looking at this code she sent us to "finish" and don't even know where to start. She said the engineering book was not necessary so I didn't bother buying it.
She wants us to write a program that will find
(a) Maximum
(b) Minimum
© Range
(d) Mean
(e ) Standard deviation
(f) Variance
(g) Median
I think some of them are already done. I need some serious help, eternal thanks to whoever helps me with this.
Here's what she sent us :/
//EGR120 assignment
//Liling Huang
//11/19/2011
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
const int size=56;
double R[size]={45.3, 67.8, 34.3, 51.2, 48.5, 61.3, 59.3, 65.1,
49.3, 42.4, 63.5, 69.8, 71.2, 39.8, 55.5, 53.2,
56.7, 48.8, 61.5, 51.2, 58.9, 63.1, 67.5, 62.4,
52.4, 50.2, 49.8, 56.8, 59.7, 60.4, 45.8, 43.8,
51.3, 54.8, 55.1, 52.3, 56.2, 59.7, 63.0, 46.7,
63.1, 58.2, 41.9, 59.2, 57.2, 67.3, 68.2, 38.9,
51.3, 63.8, 53.4, 58.9, 56.3, 58.9, 53.2, 56.8},
sum=0, mean, max=0, min=100, range, sum1, variance, std;
// Find average
for(int count=0; count<=size-1; count++)
{
sum=sum+R[count];
//cout<<sum<<" ";
//Find Maximum
if (R[count]> max)
{
max=R[count];
}
//Find Minimum
}
mean=sum/size;
range=max-min;
// Find the variance and standard devisation
for (int i=0; i<=size-1; i++)
{
sum1=sum1+( )*( );
}
variance=
std=sqrt(variance);
cout<<"The mean is "<<mean<<endl;
cout<<"The maximum is "<<max<<endl;
//cout<<"R[55]= "<<R[size-1]<<endl;
system("pause");
return 0;
}
5 replies to this topic
#1
Posted 02 December 2011 - 03:40 PM
|
|
|
#2
Posted 02 December 2011 - 05:05 PM
Do you understand what the Maximum logic is doing? Can you modify it for Minimum?
#3
Posted 02 December 2011 - 06:46 PM
I did
//Find Maximum
if (R[count]< min)
{
min=R[count];
}
but I don't even know how to run the program because I'm using an evaluation version of microsoft c++ express
//Find Maximum
if (R[count]< min)
{
min=R[count];
}
but I don't even know how to run the program because I'm using an evaluation version of microsoft c++ express
#4
Posted 03 December 2011 - 04:10 AM
you still looking for help ?
i've been using ms c++ express and doing some xna...thinking about a program of teaching programming...
anyways, i'm assuming you know how to find those mathematically
now you can use the code to do them too.
the 'variables' hold numbers in this context. you won't be using any strings of letters or alphabet stuff. ;p
you also have all the functions, this time the relevant ones being the math and print to screen (printf) ones
(also note: letters are stored as numbers too, all is bits and the hardware functions, written as c functions with () that resolve into the hardware built 'asm x86' instructinos via compiler program output files ".exe" and .o or .lib or .dll files are the 'list of binary instructions' sorta...long explanatiopn, but you get functions and variables )
also there's + , which is shorthand for both a = add(b,c); , and also add(a,b,c) ; // << add is one of the x86 instructions for registers
anyways, you now have a list of numbers (the array)
and you can use math , just like you would if you were to average them by hand....
,lemmie know if you need more help, we can chat here but if i forget, aersixb9@gmail.com
i've been using ms c++ express and doing some xna...thinking about a program of teaching programming...
anyways, i'm assuming you know how to find those mathematically
now you can use the code to do them too.
the 'variables' hold numbers in this context. you won't be using any strings of letters or alphabet stuff. ;p
you also have all the functions, this time the relevant ones being the math and print to screen (printf) ones
(also note: letters are stored as numbers too, all is bits and the hardware functions, written as c functions with () that resolve into the hardware built 'asm x86' instructinos via compiler program output files ".exe" and .o or .lib or .dll files are the 'list of binary instructions' sorta...long explanatiopn, but you get functions and variables )
also there's + , which is shorthand for both a = add(b,c); , and also add(a,b,c) ; // << add is one of the x86 instructions for registers
anyways, you now have a list of numbers (the array)
and you can use math , just like you would if you were to average them by hand....
,lemmie know if you need more help, we can chat here but if i forget, aersixb9@gmail.com
#5
Posted 12 December 2011 - 12:18 PM
hey buddy this is a interesting program I thing if you use class here it will be easier to understand and work
#6
Posted 15 December 2011 - 11:46 PM
C/C++ is a pretty universal and nice language; I have seen it used a lot. A note, though, you don't have to use a Microsoft compiler for C or C++, you can use Digital Mars - if you're familiar with the command line/console - or Pelles C, but I don't think you'll be able to use C++ with that.
Here's where I learned C++: C++ Tutorial - Introduction to C++ - Cprogramming.com
It's not exactly the best tutorial series ever, but I think it could help you get started.
Here's where I learned C++: C++ Tutorial - Introduction to C++ - Cprogramming.com
It's not exactly the best tutorial series ever, but I think it could help you get started.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









