Simple Problem With Undeclared Statements

Hey guys, this is supposed to be a simple program where a teacher can enter the marks of students, find the average, s.d and etc. I have a problem inside s.d part that i dont understand.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <iostream>

using namespace std;

//function prototypes

void readMarks(int[],int&);

void showMarks(int[],int);

void deleteMarks(int[],int&);

double Average(int[],int);

double SD(int[],int);

void countOccurences(int[],int);

void pause();

void clear();

// main function

int main()

{

int marks[20]; //to hold marks

int size=0; //for number of marks

int choise;

do

{

cout<<"\n0.Exit\n1.Add a student Marks\n2.List all student marks\n3.Average\n4.SD\n5.Delete\n6.Find Occurences"<<endl;

cout<<"\nEnter your choice-> ";

cin>>choise;

switch(choise)

{

case 1:readMarks(marks,size);break;

case 2:showMarks(marks,size);break;

case 3:cout<<endl<<Average(marks,size)<<endl;break;

case 4:cout<<endl<<SD(marks,size)<<endl;break;

case 5:deleteMarks(marks,size);break;

case 6:countOccurences(marks,size);break;

case 0:exit(0);

}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
double SD(int marks[],int size)

{

double avg=Average(marks,size);

double sd=0.0;

for(int i=0;i<size;i++)

sd+=pow((marks[i]-avg),2);

return sqrt(sd/size);

}

In function `double SD(int*, int)':
`pow' undeclared (first use this function)

(Each undeclared identifier is reported only once for each function it appears in.)

`sqrt' undeclared (first use this function)
Last edited on
closed account (3hM2Nwbp)
You'll have to #include<cmath> to gain access to pow and sqrt.

http://cplusplus.com/reference/clibrary/cmath/
I'd just like to say thank you, it works flawlessly now.
Topic archived. No new replies allowed.