user3182509
user3182509

Reputation: 1

Reading float values; output comes as 0.00000

int potenz(float x[1001], float y[1001])
{
    int i;
    float c=0.0f,k=0.0f; 


    system("clear"); 

    printf("Wahl der Potenzfunktion der Form c * x^k\n");

    printf("Bitte geben sie den Koeffizienten c ein: ");
    scanf("%f",&c);

    printf("\nBitte geben sie den Exponenten k ein: ");
    scanf("%f",&k);


    printf("\nIhre Funktion: %f x^ %f\n",&c,&k);

}

The issue is pretty simple, here is a log of input/output:

Bitte geben sie den Koeffizienten c ein: 23.512

Bitte geben sie den Exponenten k ein: 5.1

Ihre Funktion: 0.000000 x^ 0.000000

any idea why it is doing that or how to avoid that?

Upvotes: 0

Views: 737

Answers (3)

suspectus
suspectus

Reputation: 17258

For printf specify the variable, not the variable's address:

  printf("\nIhre Funktion: %f x^ %f\n",c,k);
                                       ^^^^

Upvotes: 1

Stephen Rasku
Stephen Rasku

Reputation: 2682

You are outputting the address of the floats not the floats themselves. Try changing it to:

printf("\nIhre Funktion: %f x^ %f\n",c,k);

Upvotes: 1

Roger Rowland
Roger Rowland

Reputation: 26259

You're printing the addresses of the variables c and k instead of their contents. You should do this:

printf("\nIhre Funktion: %f x^ %f\n",c,k);

Upvotes: 4

Related Questions