-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunzioni.c
69 lines (57 loc) · 883 Bytes
/
funzioni.c
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
64
65
66
67
68
69
/*
* funzioni.c
*
* Created on: 21 apr 2021
* Author: Piersilvio spicoli
*/
//includiamo le librerie standard
#include <stdio.h>
#include <stdlib.h>
#include "funzioni.h"
int somma(int a, int b)
{
return a + b;
}
int prodotto(int a, int b)
{
return a * b;
}
int quadrato(int a)
{
return a * a;
}
int dispari_pari(int a)
{
int vero = 0; //0 = falso
if(a % 2 == 0)
{
vero = 1; //il numero è pari
return vero;
}else
{
vero = -1; //il numero è dispari
return vero;
}
}
void controllo_pariDisp(int a)
{
if(a == -1)
{
puts("_> il numero è dispari!");
}else
{
puts("_> il numero è pari!");
}
}
int sottrazione(int a, int b)
{
return a - b;
}
float divisione(int a, int b)
{
return a / b;
}
int cubo(int a)
{
return a * a * a; //riutilizzo il quadrato per il suo cubo
}