JaxTeller61 JaxTeller61 - 1 month ago 8
C Question

How can I write a program to find maximum value of integer variable

In C, how can I write a program to find the maximum value of an integer variable?
As far as I know the maximum value of an integer variable is 2147483647 but how can I represent this in a C program ?

usr usr
Answer

As ı know the maximum value of a integer variable is 2147483647

That's a wrong assumption. The maximum value of an int can vary across systems. For example, on a 16-bit machine maximum value of int is not 2147483647.

You don't need to find it yourself. There are pre-defined macros which you can use from <limits.h>. For example, INT_MAX represents the maximum value an int can hold.