Q:

Matching int with element of int array in switch case

I'm getting the following error:
program.c:24:3: error: case label does not reduce to an integer constant
   case proc_id[0]: //child process 1 pid

for all case statements in the following code:
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>

int proc_id[4];

int main(int argc, char *argv[]){
    int i;

    int proc=1;
    for (i = 0; i < 3; ++i)
    {
        if(proc != 0){
            proc = fork(); 
        }
        if (proc != 0)
        {
            proc_id[i]=proc;
        }
    }

    switch(getpid()){
        case proc_id[0]: //child process 1 pid
            for (i = 0; i < l; ++i)
            {
                alarm(3);
                kill(proc_id[1], SIGUSR1);
            }
            break;

        case proc_id[1]: //child process 2 pid
            for (i = 0; i < l; ++i)
            {
                alarm(6);
                kill(proc_id[2], SIGUSR2);
            }
            break;

        case proc_id[2]: //child process 3 pid
            for (i = 0; i < l; ++i)
            {
                alarm(9);
                kill(proc_id[0], SIGUSR1);
            }
            break;

        case proc_id[3]: //parent pid
            printf("parent\n");
            break;
    }
    return(0);
}

void custom_handler(int signum){
    kill(SIGINT, getppid());
    printf("PID:%d \t Signal Number: %d\n", getpid(), signum);
}

void parent_handler(int signum){
    ++sigcount;
    switch(sigcount){
        case l:
            kill(proc_id[0], SIGTERM);
        break;
        case l+3:
            kill(proc_id[1], SIGTERM);
        break;
        case l+6:
            kill(proc_id[2], SIGTERM);
            kill(proc_id[3], SIGTERM);
        break;
    }
}

void sigterm_handler(int signum){
    exit(0);
}

I have two questions:

Why is this error occurring 
and 
Can we put an expression that evaluates to an integer as a case label?

Environment details:
Compiled program using gcc on ubuntu terminal.

A:

switch labels are evaluated at compiling time, so it must be constant expressions. You cannot put an expression that evaluates to anything.
If you want an equivalent algorithm, you have to use an if statement

A:

In
case proc_id[0]:

proc_id[0] is not a constant, it is a variable. The case label can only use a const such as:
case 10:

Similarly for the other case statements.
When you have a variable, your only option is to use if-else blocks.
int pid = getpid();
if ( pid == proc_id[0] )
{
   for (i = 0; i < l; ++i)
   {
      alarm(3);
      kill(proc_id[1], SIGUSR1);
   }
}
else if ( pid == proc_id[1] )
{
   for (i = 0; i < l; ++i)
   {
      alarm(6);
      kill(proc_id[2], SIGUSR2);
   }

}
else if ( pid == proc_id[2] )
{
   for (i = 0; i < l; ++i)
   {
      alarm(9);
      kill(proc_id[0], SIGUSR1);
   }
}
else if ( pid == proc_id[3] )
{
   printf("parent\n");
}

