Q:

Sum all integers within a range [p,q] where p and q can be entered in any order

Just started learning C, and it would be great if you could help me with the following:
I just wrote a program that calculates the sum of all the integers within a range [p, q]. Both p and q are entered in any order the user wants. So far, the program works fine when p < q, but doesn't when p > q. To reorder the values of both p and q I am using function reorder_range(), but it doesn't seem to work.
Also, I am not sure if the way I have organised the code is the proper one: a main() function that calls all the subprograms to run, rather than having everything within main().
I am looking forward to reading any suggestions to improve this piece of code!
#include <stdio.h>
#include <stdlib.h>

main() {
    int sum, range, i, p, q, aux;

    printf("Enter two integers:");
    range = scanf("%d%d", &p, &q);

    check_if_valid_value(range);  
    reorder_range(p, q, aux);
    dothesum(p, q, i, sum);
}

check_if_valid_value(range) {
    if (range != 2) {
        printf("You have not entered two integers.\n");
        exit(1);
    }
}          

int reorder_range(int p, int q, int aux) {
    if (p > q) {
        aux = p;
        p = q;
        q = aux;
    }
}

int dothesum(int p, int q, int i, int sum) {  
    for (i = p; i <= q; ++i) {
        sum = sum + i;
        printf("%d\n", sum);
    }
}

A:

There are more than one problem we are looking at here. For example, there are variables (p and q) which should be passed by reference (as mentioned in other answers), there are variables (aux, i, sum) which are not required to be passed, the return type of the functions (check_if_valid_value(range)) are not correct and some local variables (sum) were not initialized before being used. 
Here is the program that does the job for two positive numbers:
#include <stdio.h>
#include <stdlib.h>

void check_if_valid_value(int range)
{
        if (range != 2) 
        {
                printf("You have not entered two integers.\n");
                exit(1);
        }
}          

void reorder_range(int *p, int *q)
{
        int aux;

        if (*p > *q)
        {
                aux = *p;
                *p = *q;
                *q = aux;
        }
}

void dothesum(int p,int q)
{  
        int i, sum;
        sum = 0;

        for (i = p; i <= q; ++i)
        {
                sum=sum+i;
                printf("%d\n", sum);
        }

}

int main(void)
{

        int range, p, q;

        printf("Enter two integers:");
        range=scanf("%d%d",&p,&q);

        check_if_valid_value(range);
        reorder_range(&p, &q);
        dothesum(p,q);

        return 0;
}

