0

I just made this code:

#include <stdio.h>
#include <stdlib.h>
#define PI 3.1416

int main (){
    float x;

    x = PI;

    printf("x equals: %i.\n",x);

    system("pause");
    return 0;
}

and the 'Pi' number is 536870912. Can anybody tell me what is wrong?

1 Answers1

0

You're using the %i format specifier for printf. This is for signed integers. Instead use %f as x is a float.

kopecs
  • 1,545
  • 10
  • 20