Primo turno
#include <stdio.h>
#define DIM 4
int a[DIM]; float b [DIM];
int j;
leggi_a()
{ int i;
for (i=0; i<DIM; i++) scanf("%d", &a[i]);
}
main()
{
leggi_a();
for (j=0; j<DIM; j++){
b[j]=(9.0*a[j])*.2 +32;
printf ("celsius %d fahren %f ", a[j],b[j]);
if ((a[j]<0) || (b[j]<0)) printf ("**** negativa***\n");
else printf ("\n");
}
}
Secondo turno
#include <stdio.h>
#define DIM 4
#define NAUT 1.852
#define ENGL 1.609
int a[DIM]; float b[DIM],c [DIM];
int j;
leggi_a()
{ int i;
for (i=0; i<DIM; i++) scanf("%d", &a[i]);
}
main()
{
leggi_a();
for (j=0; j<DIM; j++)
{b[j]= a[j]*NAUT;
c[j]= b[j]/ENGL;
printf ("nautiche %d chilometri %f inglesi %f", a[j],b[j],c[j]);
if (b[j]>20.0) printf ("**** sopra 20 km ***\n");
else printf ("\n");}
}