Why the range of int is -32768 to 32767?

Because of how numbers are stored. Signed numbers are stored using something called “two’s complement notation”. Remember all variables have a certain amount of bits. If the most significant one of them, the one on the left, is a 0, then the number is non-negative (i.e., positive or zero), and the rest of the bits … Read more

Why use conio.h?

The conio.h header is specific to Turbo C, which predates the earliest C standard by several years. It contains routines that are specific to the DOS command line. One function here that’s frequently used is getch, which allows reading one character at a time without having to press the Enter key. It also contains gotoxy which allows placing … Read more

Convert char to int in C and C++

Depends on what you want to do: to read the value as an ascii code, you can write to convert the character ‘0’ -> 0, ‘1’ -> 1, etc, you can write Explanation:a – ‘0’ is equivalent to ((int)a) – ((int)’0′), which means the ascii values of the characters are subtracted from each other. Since 0 comes directly before 1 in the ascii … Read more

What is the behavior of integer division?

Will result always be the floor of the division? What is the defined behavior? Not quite. It rounds toward 0, rather than flooring. 6.5.5 Multiplicative operators 6 When integers are divided, the result of the / operator is the algebraic quotient with any fractional part discarded.88) If the quotient a/b is representable, the expression (a/b)*b … Read more

How do I create an array of strings in C?

If you don’t want to change the strings, then you could simply do When you do it like this you will allocate an array of two pointers to const char. These pointers will then be set to the addresses of the static strings “blah” and “hmm”. If you do want to be able to change the actual string content, … Read more

char *array and char array[]

The declaration and initialization declares a pointer array and make it point to a constant array of 31 characters. The declaration and initialization declares an array of characters, containing 31 characters. And yes, the size of the arrays is 31, as it includes the terminating ‘\0’ character. Laid out in memory, it will be something like this for the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)