This repository has been archived by the owner on Jun 16, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
847c447
commit a6b0eae
Showing
14 changed files
with
234 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Tipi di dato | ||
## sizeof(<espressione>) | ||
Ritorna la dimensione di un tipo di dato oppure di un espressione (variabile, espressione numerica, confronto) | ||
|
||
TODO: vedi esercizio | ||
|
||
## Overflow | ||
=> se accettiamo valori più grossi di quelli consentiti | ||
|
||
Quando il valore di un espressione è troppo grande per essere contenuto. No errori. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Fasi sviluppo | ||
## Attori | ||
Programmatore, compilatore, utente (utonto) | ||
|
||
## Fasi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Miniprova prima parte | ||
|
||
## PARTE 1 | ||
1) a | ||
2) c | ||
3) d -> Il risultato di un assegnamento (b=8) è l'lvalue della variabile, ovvero l'indirizzo in memoria di b. | ||
|
||
## PARTE 2 | ||
4) a, c | ||
|
||
## PARTE 3 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
int main() { | ||
int a, b, sel; | ||
cout << | ||
"1 --> +\n" | ||
"2 --> -\n" | ||
"3 --> *\n" | ||
"4 --> /\n" | ||
"5 --> resto divisione intera\n" | ||
"\n"; | ||
|
||
cout << "Inserire a: "; | ||
cin >> a; | ||
|
||
cout << "Inserire b: "; | ||
cin >> b; | ||
|
||
cout << "Selezione: "; | ||
cin >> sel; | ||
|
||
switch (sel) { | ||
case 1: | ||
cout << a << " + " << b << " = " << a+b; | ||
break; | ||
case 2: | ||
cout << a << " - " << b << " = " << a-b; | ||
break; | ||
case 3: | ||
cout << a << " * " << b << " = " << a*b; | ||
break; | ||
case 4: | ||
if (b == 0) { | ||
cout << "Operazione non valida"; | ||
break; | ||
} | ||
cout << a << " / " << b << " = " << a/b; | ||
break; | ||
case 5: | ||
if (b == 0) { | ||
cout << "Operazione non valida"; | ||
break; | ||
} | ||
cout << a << " % " << b << " = " << a%b; | ||
break; | ||
default: | ||
cout << "Opzione inesistente"; | ||
} | ||
cout << endl; | ||
// Miglioramenti: usa flag, ritorna exit code diverso da 0 in caso di errore | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
int main() { | ||
int b = 0; | ||
if (b=0) | ||
cout << "true" << endl; | ||
else | ||
cout << "false" << endl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
int main() { | ||
int i = | ||
// TODO | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
int main() { | ||
int ; | ||
// TODO: verifica overflow somma e sottrazione | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// TODO: verifica overflow in prodotto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
int main() { | ||
cout << "Dimensione int su questa macchina: " << sizeof(int) << " bytes" << endl; | ||
cout << "Dimensione 10+50 su questa macchina: " << sizeof(10+50) << " bytes" << endl; | ||
cout << "Dimensione bool su questa macchina: " << sizeof(1<2) << " bytes" << endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
int main() { | ||
int a = 2, n; | ||
cin >> n; | ||
switch (n) { | ||
case 1: | ||
cout << "Ramo A"; | ||
break; | ||
case 2: | ||
cout << "Ramo B"; | ||
a = a*a; | ||
break; | ||
case 3: | ||
cout << "Ramo C"; | ||
a = a*a*a; | ||
// break; | ||
default: | ||
a = 1; | ||
} | ||
|
||
cout << endl << a << endl; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
int main() { | ||
int n; | ||
|
||
cout << "1\tOpzione A\n" | ||
"2\tOpzione B\n" | ||
"3\tOpzione C\n" | ||
"4\tOpzione D\n" | ||
"\n"; | ||
|
||
cout << "Scegli un opzione: "; | ||
cin >> n; | ||
|
||
switch (n) { | ||
case 1: | ||
cout << "Opzione A"; | ||
break; | ||
case 2: | ||
cout << "Opzione B"; | ||
break; | ||
case 3: | ||
cout << "Opzione C"; | ||
break; | ||
case 4: | ||
cout << "Opzione D"; | ||
break; | ||
default: | ||
cout << "Scelta non valida"; | ||
} | ||
cout << endl; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
int main() { | ||
int n; | ||
|
||
cout << "1\tOpzione A\n" | ||
"3\tOpzione B\n" | ||
"4\tOpzione C\n" | ||
"5\tOpzione C\n" | ||
"6\tOpzione D\n" | ||
"\n"; | ||
|
||
cout << "Scegli un opzione: "; | ||
cin >> n; | ||
|
||
switch (n) { | ||
case 1: | ||
cout << "Opzione A"; | ||
break; | ||
case 3: | ||
cout << "Opzione B"; | ||
break; | ||
case 4: | ||
case 5: | ||
cout << "Opzione C"; | ||
break; | ||
case 6: | ||
cout << "Opzione D"; | ||
break; | ||
default: | ||
cout << "Scelta non valida"; | ||
} | ||
cout << endl; | ||
|
||
return 0; | ||
} |