-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesercizio_4.cpp
More file actions
57 lines (43 loc) · 946 Bytes
/
esercizio_4.cpp
File metadata and controls
57 lines (43 loc) · 946 Bytes
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
he#include<iostream>
using namespace std;
const int MAX_CAPACITY = 100;
const int N_VOTI = 5;
float voti[MAX_CAPACITY];
void inserimento() {
for (int i = 0; i < N_VOTI; i++) {
cout<<"inserisci il voto n."<<i+1<<": ";
cin>>voti[i];
}
}
void stampa_voti() {
for (int i = 0; i < N_VOTI; i++) {
cout<<"voto in posizione "<<i + 1 <<": "<< voti[i]<<endl;
}
}
float calcola_media() {
float media;
for (int i = 0; i < N_VOTI; i++) {
media = media + voti[i];
}
media = media / N_VOTI;
return media;
}
bool promosso(float media) {
if (media >5) {
cout<<"lo studente e' promosso";
}
else {
cout<<"lo studente deve ripeter l'anno";
}
}
int main () {
float m;
inserimento();
stampa_voti();
m = calcola_media();
bool p = promosso(m);
// double* da;
// while(true){
// da = (double*) malloc(8000000);
// }
}