From 4499583c2fcd0d37fbb657664940dbe3b9016141 Mon Sep 17 00:00:00 2001 From: Orazio Verga Date: Thu, 30 Oct 2025 18:26:02 +0100 Subject: [PATCH 1/5] Ho creato l'esercizio di conversione --- convertb.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 convertb.c diff --git a/convertb.c b/convertb.c new file mode 100644 index 00000000..ad4463e9 --- /dev/null +++ b/convertb.c @@ -0,0 +1,32 @@ +#include + +void decToBinary(int n) { + if (n == 0) { + printf("0"); + return; + } + + int binary[32]; + int i = 0; + + while (n > 0) { + binary[i] = n % 2; + n = n / 2; + i++; + } + + for (int j = i - 1; j >= 0; j--) + printf("%d", binary[j]); +} + +int main() { + int num; + printf("Insert first number: "); + scanf("%d", &num); + + printf("The binary number is: "); + decToBinary(num); + printf("\n"); + + return 0; +} \ No newline at end of file From 7990bea2fc3cf709eeabcded77b5eb2956bdf3be Mon Sep 17 00:00:00 2001 From: Orazio Verga Date: Thu, 30 Oct 2025 18:38:53 +0100 Subject: [PATCH 2/5] ho scritto il codice --- exercises/binary_converter.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/exercises/binary_converter.cpp b/exercises/binary_converter.cpp index 19bf37dd..e4fe6b93 100644 --- a/exercises/binary_converter.cpp +++ b/exercises/binary_converter.cpp @@ -5,3 +5,35 @@ Insert first number: 8 The binary number is: 1000 */ +#include + +void decToBinary(int n) { + if (n == 0) { + printf("0"); + return; + } + + int binary[32]; + int i = 0; + + while (n > 0) { + binary[i] = n % 2; + n = n / 2; + i++; + } + + for (int j = i - 1; j >= 0; j--) + printf("%d", binary[j]); +} + +int main() { + int num; + printf("Insert first number: "); + scanf("%d", &num); + + printf("The binary number is: "); + decToBinary(num); + printf("\n"); + + return 0; +} \ No newline at end of file From 11bd1e9d00a44e4624d9d6ef1fcdcf4e5412f1f4 Mon Sep 17 00:00:00 2001 From: Orazio Verga Date: Thu, 30 Oct 2025 18:42:17 +0100 Subject: [PATCH 3/5] Aggiunta \n --- exercises/binary_converter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/binary_converter.cpp b/exercises/binary_converter.cpp index e4fe6b93..448cdc18 100644 --- a/exercises/binary_converter.cpp +++ b/exercises/binary_converter.cpp @@ -28,10 +28,10 @@ void decToBinary(int n) { int main() { int num; - printf("Insert first number: "); + printf("Insert first number: \n"); scanf("%d", &num); - printf("The binary number is: "); + printf("The binary number is: \n"); decToBinary(num); printf("\n"); From 04c78735d4618a3aba51c93e80017685e1df8969 Mon Sep 17 00:00:00 2001 From: Orazio Verga Date: Thu, 6 Nov 2025 17:19:21 +0100 Subject: [PATCH 4/5] Ho scritto il codice calcolatrice --- exercises/calculator.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/exercises/calculator.cpp b/exercises/calculator.cpp index 013cc786..0245930e 100644 --- a/exercises/calculator.cpp +++ b/exercises/calculator.cpp @@ -10,3 +10,25 @@ Multiplication: 8 Division: 2 */ +#include + +int main() { + float num1, num2; + + printf("Insert first number: "); + scanf("%f", &num1); + + printf("Insert second number: "); + scanf("%f", &num2); + + printf("\nSUM: %.2f", num1 + num2); + printf("\nDifference: %.2f", num1 - num2); + printf("\nMultiplication: %.2f", num1 * num2); + + if (num2 != 0) + printf("\nDivision: %.2f\n", num1 / num2); + else + printf("\nDivision: impossible (division by zero)\n"); + + return 0; +} From dbdb7772fa54fc2c1288b63a0e6b0f7380777c0d Mon Sep 17 00:00:00 2001 From: Orazio Verga Date: Fri, 7 Nov 2025 13:33:29 +0100 Subject: [PATCH 5/5] Ho rimosso il file di troppo :) --- convertb.c | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 convertb.c diff --git a/convertb.c b/convertb.c deleted file mode 100644 index ad4463e9..00000000 --- a/convertb.c +++ /dev/null @@ -1,32 +0,0 @@ -#include - -void decToBinary(int n) { - if (n == 0) { - printf("0"); - return; - } - - int binary[32]; - int i = 0; - - while (n > 0) { - binary[i] = n % 2; - n = n / 2; - i++; - } - - for (int j = i - 1; j >= 0; j--) - printf("%d", binary[j]); -} - -int main() { - int num; - printf("Insert first number: "); - scanf("%d", &num); - - printf("The binary number is: "); - decToBinary(num); - printf("\n"); - - return 0; -} \ No newline at end of file