We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4befc1a commit fe8830fCopy full SHA for fe8830f
Harmonic_series.c
@@ -0,0 +1,30 @@
1
+/*DAVIDE GIANNUBILO - Esercizi Linguaggio C
2
+Scrivere un programma che calcoli la serie armonica di un numero N inserito in ingresso
3
+Write a program that calculates the Harmonic series of a number N given in input
4
+*/
5
+
6
+#include<stdio.h>
7
8
+int main()
9
+{
10
+ int num;
11
+ printf("Inserisci il numero n: ");
12
+ scanf("%d", &num);
13
14
+ if(num<=0)
15
+ {
16
+ printf("Errore! Numero <= 0\n");
17
+ return 0;
18
+ }
19
+ else
20
21
+ float somma;
22
+ for(float i=1; i<=num; i++)
23
24
+ somma=somma+1/i;
25
26
+ printf("La serie armonica vale: %f\n", somma);
27
28
29
30
+}
0 commit comments