Program to determine ranges of char, short, int and long variables, both signed and unsigned I wrote code to determinate ranges of char,short int and long variables,both signed and unsigned.Please help me to improve my code :) Here is the code:

#include &lt;stdio.h&gt;

//function declerations...
long power(int base, int power);

int main(void) {
    //From 2^(N-1) to 2^(N-1)-1 (Two's complement)
    int intmin = power(2, sizeof(int) * 8 - 1);
    int intmax = power(2, sizeof(int) * 8 - 1) - 1;
    unsigned unsignedintmax = power(2, sizeof(int) * 8) - 1;
    char minchar = -(power(2, sizeof(char) * 8 - 1));
    char maxchar = power(2, sizeof(char) * 8 - 1) - 1;
    unsigned char unsignedcharmax = power(2, sizeof(char) * 8) - 1;
    short shortmin = -(power(2, sizeof(short) * 8 - 1));
    short shortmax = power(2, sizeof(short) * 8 - 1) - 1;
    unsigned short unsignedshortmax = power(2, sizeof(short) * 8) - 1;
    long minlong = power(2, sizeof(long) * 8 - 1);
    long maxlong = power(2, sizeof(long) * 8 - 1) - 1;
    unsigned long unsignedlongmax = power(2, sizeof(long) * 8) - 1;
    minlong*=-1;
    printf("\nSigned char can be minimum: %d and maximum: %d\n", minchar, maxchar);
    printf("\nUnsigned char can be minimum: %d and maximum: %u\n", 0, unsignedcharmax);
    printf("\nSigned short can be minimum: %d and maximum: %d\n", shortmin, shortmax);
    printf("\nUnsigned short can be minimum: %d and maximum: %u\n", 0, unsignedshortmax);
    printf("\nSigned int can be minimum: %d and maximum: %d\n", intmin, intmax);
    printf("\nUnsigned int can be minimum: %d and maximum: %u\n", 0, unsignedintmax);
    printf("\nSigned long can be minimum: %ld and maximum: %ld\n", minlong, maxlong);
    printf("\nUnsigned long can be minimum: %d and maximum: %lu\n\n", 0, unsignedlongmax);

    return 0;
}

long power(int base, int power) {
    long pf = 1;
    for (int i = 0; i &lt; power; i++) {
        pf *= base;
    }
    return pf;
}
Signedness of unqualified char is implementation defined. It may well be possible that char is in fact unsigned. Change char to signed char.
A char is not guaranteed to have 8 bits (it is guaranteed to have at least 8 bits). Use CHAR_BIT instead.
Narrowing types (e.g. assigning long to char) always make me uncomfortable. A better technique to get a value with only MSB set is (TYPE is either char,int,long,whatever) 

unsigned TYPE value = ~(((unsigned TYPE) -1) &gt;&gt; 1)