Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created...
Transcript of Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created...
![Page 2: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/2.jpg)
![Page 3: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/3.jpg)
![Page 4: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/4.jpg)
▪
▪
▪
![Page 5: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/5.jpg)
![Page 6: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/6.jpg)
▪
▪
▪
▪
![Page 7: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/7.jpg)
▪
▪
▪
Unità di
Elaborazione
(CPU)
Memoria
Centrale (MM)
Interfaccia
Input
Interfaccia
Output
Bus d
i sis
tem
a
![Page 8: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/8.jpg)
![Page 9: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/9.jpg)
▪
▪
a, x, alfa, pippo, a1, Giuseppe,
DopoDomani, velocita_massima
▪
Alfa alfa ALPHA
▪
![Page 10: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/10.jpg)
Pippo
Pippo
a
...
![Page 11: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/11.jpg)
![Page 12: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/12.jpg)
▪ char
[0,255]
▪ int
▪ float
▪ double
![Page 13: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/13.jpg)
▪
▪
keywordTipo nomeVariabile;
int a
▪
keywordTipo nomeVariabile1, nomeVariabile2;
int a, b;
![Page 14: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/14.jpg)
▪
keywordTipo nomeVariabile1 = valIniziale;
int a = 0, b = 8;
▪
▪
![Page 15: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/15.jpg)
![Page 16: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/16.jpg)
▪
▪
▪
▪
![Page 17: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/17.jpg)
nomeVariabile = espressione;
nomeVariabile
espressione
nomeVariabile
espressione
+ − * /
a = 7; k = 9.02; a = (3 – 214) * 2;
a = b; a = a + 1;
![Page 18: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/18.jpg)
nomeVariabile = espressione;
nomeVariabile
espressione
espressione
nomeVariabile
=
==
![Page 19: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/19.jpg)
▪ ‘’
▪ char
char a;
a = ‘A’;
a = ‘z’;
a = ‘1’;
a
1
![Page 20: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/20.jpg)
▪ + - * /
int
int a,b;
float c;
c = a / b;
float
int a,b;
float c;
c = (1.0 * a) / b;
float a, b, c;
c = a / b;
![Page 21: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/21.jpg)
int
▪ = int int
▪ + int int
▪ - int int
▪ * int int
▪ /int
▪ %
▪ ==
▪ !=
▪ <
▪ >
▪ <=
▪ >=
![Page 22: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/22.jpg)
▪
%
17%5 2 15%5 0
▪ a b a = (a/b)*b + a % b;
int a = 11; int b = 4; int c;
a = a + 1;
c = a / b;
int a = 12; int b = 5; int c;
c = a / b;
a 12
c 3
c 2
![Page 23: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/23.jpg)
▪
%
17%5 2 15%5 0
▪ a b a = (a/b)*b + a % b;
int a = 11; int b = 4; int c;
c = a % 2;
int a = 70; int b = 5; int c;
c = a % (b + 2);
b b
b = b + 2; c = a % b;
c 1
c 0
![Page 24: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/24.jpg)
▪ printf
▪ scanf
Interfaccia
Input
Interfaccia
Output
![Page 25: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/25.jpg)
▪
printf (stringaControllo);
stringaControllo
(" "
stringaControllo
▪
scanf("%d", &a);
a
a
![Page 26: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/26.jpg)
printf("Inserire A");
![Page 27: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/27.jpg)
scanf("%d", &a);
![Page 28: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/28.jpg)
![Page 29: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/29.jpg)
▪
▪
istr1;
istr2;
istr3;
istr4;
…
istr2;
istr3;
istr4;
istr1;
![Page 30: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/30.jpg)
▪
▪
▪ int a,z,x;
a = 45;
z = 5;
x = (a – z) / 10;
▪
![Page 31: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/31.jpg)
▪
▪
▪ int a,z,x;
a = 45;
z = 5;
x = (a – z) / 10;
▪
![Page 32: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/32.jpg)
▪
▪
▪ int a,z,x;
a = 45;
z = 5;
x = (a – z) / 10;
▪
![Page 33: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/33.jpg)
▪
▪
▪ int a,z,x;
a = 45;
z = 5;
x = (a – z) / 10;
▪
![Page 34: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/34.jpg)
![Page 35: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/35.jpg)
/* commenti
commenti */
#include<stdio.h>
void main()
// punto di inizio
{
printf("Hello world!");
}
![Page 36: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/36.jpg)
/* commenti
commenti */
#include<stdio.h>
void main()
// punto di inizio
{
printf("Hello world!");
}
▪
• /* */
• //
![Page 37: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/37.jpg)
▪
▪ #include
#include<nomeLibreria.h>
nomeLibreria.h
▪ stdio.h
printf scanf
/* commenti
commenti */
#include<stdio.h>
void main()
// punto di inizio
{
printf("Hello world!");
}
![Page 38: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/38.jpg)
▪
main
▪
▪
main
▪
▪
int main(){…
return 0;}
void main(){…}
/* commenti
commenti */
#include<stdio.h>
void main()
// punto di inizio
{
printf("Hello world!");
}
![Page 39: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/39.jpg)
▪
▪
Hello world
/* commenti
commenti */
#include<stdio.h>
void main()
// punto di inizio
{
printf("Hello world!");
}
![Page 40: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/40.jpg)
/* eseguire la somma di due
numeri inseriti dall'utente*/
# include<stdio.h>
void main()
{
int a, b, somma;
printf("Inserire a:");
scanf("%d" , &a);
printf("Inserire b:");
scanf("%d" , &b);
somma = a + b;
printf("\n %d + %d = %d",
a, b, somma);
}
▪
![Page 41: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/41.jpg)
/* eseguire la somma di due
numeri inseriti dall'utente*/
# include<stdio.h>
void main()
{
int a, b, somma;
printf("Inserire a:");
scanf("%d" , &a);
printf("Inserire b:");
scanf("%d" , &b);
somma = a + b;
printf("\n %d + %d = %d",
a, b, somma);
}
▪
▪
![Page 42: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/42.jpg)
![Page 43: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/43.jpg)
▪ printf
▪ scanf
Interfaccia
Input
Interfaccia
Output
![Page 44: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/44.jpg)
printf
printf("\nInserire a:");
printf (stringaControllo);
• stringaControllo
−
stringaControllo
![Page 45: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/45.jpg)
printf
printf("\n %d + %d = %d", a, b, a+b);
printf (stringaControllo, elementiStampa);
• stringaControllo
−
−
• elementiStampa
elementiStampa
stringaControllo
![Page 46: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/46.jpg)
stringaControllo
▪
• ‘\n’
• ‘\t’
▪
• %d
• %f
• %c
• %s
![Page 47: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/47.jpg)
printf
int cat_dipend = 1;
float stip_medio = 35623.5;
printf ("Lo stipendio annuo dei dipendenti
di categoria %d è pari a $%f", cat_dipend,
stip_medio);
![Page 48: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/48.jpg)
printf
int cat_dipend = 1;
float stip_medio = 35623.5;
printf ("Lo stipendio annuo dei dipendenti
di categoria %d è pari a $%f", cat_dipend,
stip_medio);
%d cat_dipend
%f stip_medio
![Page 49: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/49.jpg)
printf
int cat_dipend = 1;
float stip_medio = 35623.5;
printf ("Lo stipendio annuo dei dipendenti
di categoria %d è pari a $%f", cat_dipend,
stip_medio);
▪
![Page 50: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/50.jpg)
printf
char iniz_nome = ‘F’;
char iniz_cognome = ‘T’;
printf("Questo programma è stato scritto da
\n%c%c\n\nBuon lavoro!\n", iniz_nome,
iniz_cognome);
![Page 51: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/51.jpg)
printf
char iniz_nome = ‘F’;
char iniz_cognome = ‘T’;
printf("%s\n%c%c\n\n%s\n", "Questo
programma è stato scritto da", iniz_nome,
iniz_cognome, "Buon lavoro!");
▪
stringaControllo
%s
![Page 52: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/52.jpg)
printf
char iniz_nome = ‘F’;
char iniz_cognome = ‘T’;
printf("Questo programma è stato scritto da
\n%c%c\n\nBuon lavoro!\n", iniz_nome,
iniz_cognome);
![Page 53: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/53.jpg)
scanf
▪
scanf("%d", &b);
▪
scanf(stringaControllo, indirizzoVariabile)
• stringaControllo:
• indirizzoVariabile:
▪
stringaControllo
indirizzoVariabile
![Page 54: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/54.jpg)
▪
&
char Pippo;
Pippo = ‘a’;
&Pippo
Pippo
‘a’Pippo
![Page 55: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/55.jpg)
scanf
▪ int x;
scanf("%d", &x);
▪ float x;
scanf("%f", &x);
▪ double x;
scanf("%f", &x);
▪ int x,y;
float z;
scanf("%d%d%f", &x,&y,&z);
![Page 56: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/56.jpg)
![Page 57: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/57.jpg)
// conversione da gradi Fahrenheit
a Celsius
#include <stdio.h>
void main(){
int Ftemp;
float Ctemp;
printf("Inserire la
temperatura in Fahrenheit da
convertire in Celsius\n");
scanf("%d", &Ftemp);
Ctemp = (5.0/9)*(Ftemp - 32);
printf("in Celsius %f" ,
Ctemp);
}
▪
▪
𝐶 = 5/9 ∗ (𝐹 − 32)
![Page 58: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/58.jpg)
▪
![Page 59: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/59.jpg)
# include<stdio.h>
void main()
{
char a,b,c;
printf("\nInserire il carat. A = ");
scanf("%c" , &a);
fflush(stdin);
printf("\nInserire il carat. B = ");
scanf("%c" , &b);
c = a; // salvo in c il valore di a
a = b;
b = c;
printf("\nA = %c", a);
printf("\nB = %c", b);
}
▪
▪
![Page 60: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/60.jpg)
# include<stdio.h>
void main()
{
char a,b,c;
printf("\nInserire il carat. A = ");
scanf("%c" , &a);
fflush(stdin);
printf("\nInserire il carat. B = ");
scanf("%c" , &b);
c = a; // salvo in c il valore di a
a = b;
b = c;
printf("\nA = %c", a);
printf("\nB = %c", b);
}
fflush(stdin);
scanf("%c", &b);
![Page 61: Informatica B Boracchi - trovo.faculty.polimi.it · Informatica_B_Boracchi Author: giacomo Created Date: 9/24/2019 8:52:15 AM ...](https://reader033.fdocuments.nl/reader033/viewer/2022042404/5f1bcfaa7e708259f47fd27a/html5/thumbnails/61.jpg)