Quick Question

+1 Skill Shot · March 28, 2015
Hello guys,

I started programming like 2 days ago and I totally fell in love with thenewboston's awesome tutorials about C programming on youtube, which brought me here :)

I don't know if there is a section for presentations, if so i'll get there to present myself :)

I just have a little question about the "C Programming Tutorial - 10 - Creating a Header File".

I past what i wrote :


(main.c) <--- file1

1     #include <stdio.h>
2     #include <stdlib.h>
3     #include "TEST2.h"
5     int main()
6     {
8     int BMI = Weights/Heights*Heights;                                      (<-- i don't know how to square a number, same for cube, etc)
9     printf("My BMI equals to %d\n\n", BMI);
11   return 0;
13   }


(TEST2.h) <--- file2

1     #define Weights = 69
2     #define Heights = 175


When i build and run it shows a problem at this lign :  int BMI = Weights/Heights*Heights; but i really don't know why...
If someone can help me it would really be nice :)

Thank you by advance.

Post a Reply


Oldest  Newest  Rating
0 Dol Lod · March 28, 2015
Macros do not use equal signs when you simply want to define a constant like an int

Here is an example of how to define a macro

ex. 1

#define Weights 69


#define Heights 175

Include math.h for computations involving exponents and look at the pow function.
0 Skill Shot · March 28, 2015
Mhh yup it's a mistake i made on the forum.
The file2 in my program is "TEST2.h", i just forgot to add the "2" on the forum, i'll modify my previous post.

So i still dunno why it doesn't want to build and run :ermm:

For the math.h thing i don't understand what you mean but maybe i'll discover later.

Anyway, thanks for answering :)
0 Skill Shot · March 28, 2015
Ahh you are right, i was using the equal sign to define something :)
Now I can build and run the program again, perfect ! :D

Thanks a lot for helping me Arjun Patel !
0 Dol Lod · March 28, 2015
  • 1



One of the most popular languages of all time.

Bucky Roberts Administrator