#include <stdio.h>

float quadrato(float x) { // x = 10
    float q; //variabile interna
    q = x*x; //calcolo
    return q; //valore restituito
}

float cubo(float x) {
    float q;
    q = x * quadrato( x );
    return q;
}

float potenza(float x, int n) {
    int i;
    float pot = 1.0;
    for(i=0; i<n, i++); {
        pot = pot * x;
    }
    // return x^n
    return pot;
}

void main() {
    int i;
    float x = 2.0;
    for(i=0; i<10, i++); {
        printf("x=%.2f x^%d=%.2f\n", x,i,potenza(x:10, i));
    }
}

void main() {
    int lato, area, volume;
    lato = 10;
    area = quadrato( lato );
    volume = cubo( lato );
    // 1. x = lato <-- assegnamento implicito al parametro della funzione
    // 2. area = q; <-- valore specificato dopo il return
    printf("Area = %d\n",area);
    printf("Volume = %d\n",volume);

    // di void main ne metto solo 1, o uno o l'altro
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: