Language: C

void throwdice(char ch, struct DICE *dice)
{
	int temp;
	switch (ch) {
	case 'N':
		temp = dice->num[6] ;
		dice->num[6] = dice->num[5] ;
		dice->num[5] = dice->num[1] ;
		dice->num[1] = dice->num[2] ;
		dice->num[2] = temp;
		break;
	case 'S':
		temp = dice->num[6] ;
		dice->num[6] = dice->num[2] ;
		dice->num[2] = dice->num[1] ;
		dice->num[1] = dice->num[5] ;
		dice->num[5] = temp;
		break;
	case 'E':
		temp = dice->num[6] ;
		dice->num[6] = dice->num[3] ;
		dice->num[3] = dice->num[1] ;
		dice->num[1] = dice->num[4] ;
		dice->num[4] = temp;
		break;
	case 'W':
		temp = dice->num[6] ;
		dice->num[6] = dice->num[4] ;
		dice->num[4] = dice->num[1] ;
		dice->num[1] = dice->num[3] ;
		dice->num[3] = temp;
		break;
	}
}

int rot(int top, int front, struct DICE *dice)
{
	int cnt;
	cnt = 0;
	while (dice->num[2] != front) {
		if (dice->num[3] == front || dice->num[4] == front) {
			throwdice('E', dice);
		}
		throwdice('N', dice);
		cnt++;
		if(cnt == 4) {
			return -1;
		}
	}
	cnt = 0;
	while (dice->num[1] != top) {
		throwdice('E', dice);
		cnt++;
		if(cnt == 4) {
			return -1;
		}
	}
	return 0;
}

int main(void)
{
	struct DICE dice;
	int i, q, top, front, right;
	
	for(i=1; i<=6; i++) {
		scanf("%d",&dice.num[i]);
	}
	scanf("%d",&q);
	for (i=0; i<q; i++) {
		scanf("%d %d",&top,&front);
		rot(top, front, &dice);
		printf("%d\n", dice.num[3]);
	}
	return 0;
}

Compiler output:
main.c:1:32: warning: 'struct DICE' declared inside parameter list will not be visible outside of this definition or declaration
    1 | void throwdice(char ch, struct DICE *dice)
      |                                ^~~~
main.c: In function 'throwdice':
main.c:6:28: error: invalid use of undefined type 'struct DICE'
    6 |                 temp = dice->num[6] ;
      |                            ^~
main.c:7:21: error: invalid use of undefined type 'struct DICE'
    7 |                 dice->num[6] = dice->num[5] ;
      |                     ^~
main.c:7:36: error: invalid use of undefined type 'struct DICE'
    7 |                 dice->num[6] = dice->num[5] ;
      |                                    ^~
main.c:8:21: error: invalid use of undefined type 'struct DICE'
    8 |                 dice->num[5] = dice->num[1] ;
      |                     ^~
main.c:8:36: error: invalid use of undefined type 'struct DICE'
    8 |                 dice->num[5] = dice->num[1] ;
      |                                    ^~
main.c:9:21: error: invalid use of undefined type 'struct DICE'
    9 |                 dice->num[1] = dice->num[2] ;
      |                     ^~
main.c:9:36: error: invalid use of undefined type 'struct DICE'
    9 |                 dice->num[1] = dice->num[2] ;
      |                                    ^~
main.c:10:21: error: invalid use of undefined type 'struct DICE'
   10 |                 dice->num[2] = temp;
      |                     ^~
main.c:13:28: error: invalid use of undefined type 'struct DICE'
   13 |                 temp = dice->num[6] ;
      |                            ^~
main.c:14:21: error: invalid use of undefined type 'struct DICE'
   14 |                 dice->num[6] = dice->num[2] ;
      |                     ^~
main.c:14:36: error: invalid use of undefined type 'struct DICE'
   14 |                 dice->num[6] = dice->num[2] ;
      |                                    ^~
main.c:15:21: error: invalid use of undefined type 'struct DICE'
   15 |                 dice->num[2] = dice->num[1] ;
      |                     ^~
main.c:15:36: error: invalid use of undefined type 'struct DICE'
   15 |                 dice->num[2] = dice->num[1] ;
      |                                    ^~
main.c:16:21: error: invalid use of undefined type 'struct DICE'
   16 |                 dice->num[1] = dice->num[5] ;
      |                     ^~
main.c:16:36: error: invalid use of undefined type 'struct DICE'
   16 |                 dice->num[1] = dice->num[5] ;
      |                                    ^~
main.c:17:21: error: invalid use of undefined type 'struct DICE'
   17 |                 dice->num[5] = temp;
      |                     ^~
main.c:20:28: error: invalid use of undefined type 'struct DICE'
   20 |                 temp = dice->num[6] ;
      |                            ^~
main.c:21:21: error: invalid use of undefined type 'struct DICE'
   21 |                 dice->num[6] = dice->num[3] ;
      |                     ^~
main.c:21:36: error: invalid use of undefined type 'struct DICE'
   21 |                 dice->num[6] = dice->num[3] ;
      |                                    ^~
main.c:22:21: error: invalid use of undefined type 'struct DICE'
   22 |                 dice->num[3] = dice->num[1] ;
      |                     ^~
main.c:22:36: error: invalid use of undefined type 'struct DICE'
   22 |                 dice->num[3] = dice->num[1] ;
      |                                    ^~
main.c:23:21: error: invalid use of undefined type 'struct DICE'
   23 |                 dice->num[1] = dice->num[4] ;
      |                     ^~
main.c:23:36: error: invalid use of undefined type 'struct DICE'
   23 |                 dice->num[1] = dice->num[4] ;
      |                                    ^~
main.c:24:21: error: invalid use of undefined type 'struct DICE'
   24 |                 dice->num[4] = temp;
      |                     ^~
main.c:27:28: error: invalid use of undefined type 'struct DICE'
   27 |                 temp = dice->num[6] ;
      |                            ^~
main.c:28:21: error: invalid use of undefined type 'struct DICE'
   28 |                 dice->num[6] = dice->num[4] ;
      |                     ^~
main.c:28:36: error: invalid use of undefined type 'struct DICE'
   28 |                 dice->num[6] = dice->num[4] ;
      |                                    ^~
main.c:29:21: error: invalid use of undefined type 'struct DICE'
   29 |                 dice->num[4] = dice->num[1] ;
      |                     ^~
main.c:29:36: error: invalid use of undefined type 'struct DICE'
   29 |                 dice->num[4] = dice->num[1] ;
      |                                    ^~
main.c:30:21: error: invalid use of undefined type 'struct DICE'
   30 |                 dice->num[1] = dice->num[3] ;
      |                     ^~
main.c:30:36: error: invalid use of undefined type 'struct DICE'
   30 |                 dice->num[1] = dice->num[3] ;
      |                                    ^~
main.c:31:21: error: invalid use of undefined type 'struct DICE'
   31 |                 dice->num[3] = temp;
      |                     ^~
main.c: At top level:
main.c:36:36: warning: 'struct DICE' declared inside parameter list will not be visible outside of this definition or declaration
   36 | int rot(int top, int front, struct DICE *dice)
      |                                    ^~~~
main.c: In function 'rot':
main.c:40:20: error: invalid use of undefined type 'struct DICE'
   40 |         while (dice->num[2] != front) {
      |                    ^~
main.c:41:25: error: invalid use of undefined type 'struct DICE'
   41 |                 if (dice->num[3] == front || dice->num[4] == front) {
      |                         ^~
main.c:41:50: error: invalid use of undefined type 'struct DICE'
   41 |                 if (dice->num[3] == front || dice->num[4] == front) {
      |                                                  ^~
main.c:42:40: error: passing argument 2 of 'throwdice' from incompatible pointer type [-Wincompatible-pointer-types]
   42 |                         throwdice('E', dice);
      |                                        ^~~~
      |                                        |
      |                                        struct DICE *
main.c:1:38: note: expected 'struct DICE *' but argument is of type 'struct DICE *'
    1 | void throwdice(char ch, struct DICE *dice)
      |                         ~~~~~~~~~~~~~^~~~
main.c:44:32: error: passing argument 2 of 'throwdice' from incompatible pointer type [-Wincompatible-pointer-types]
   44 |                 throwdice('N', dice);
      |                                ^~~~
      |                                |
      |                                struct DICE *
main.c:1:38: note: expected 'struct DICE *' but argument is of type 'struct DICE *'
    1 | void throwdice(char ch, struct DICE *dice)
      |                         ~~~~~~~~~~~~~^~~~
main.c:51:20: error: invalid use of undefined type 'struct DICE'
   51 |         while (dice->num[1] != top) {
      |                    ^~
main.c:52:32: error: passing argument 2 of 'throwdice' from incompatible pointer type [-Wincompatible-pointer-types]
   52 |                 throwdice('E', dice);
      |                                ^~~~
      |                                |
      |                                struct DICE *
main.c:1:38: note: expected 'struct DICE *' but argument is of type 'struct DICE *'
    1 | void throwdice(char ch, struct DICE *dice)
      |                         ~~~~~~~~~~~~~^~~~
main.c: In function 'main':
main.c:63:21: error: storage size of 'dice' isn't known
   63 |         struct DICE dice;
      |                     ^~~~
main.c:67:17: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   67 |                 scanf("%d",&dice.num[i]);
      |                 ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | void throwdice(char ch, struct DICE *dice)
main.c:67:17: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   67 |                 scanf("%d",&dice.num[i]);
      |                 ^~~~~
main.c:67:17: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:69:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   69 |         scanf("%d",&q);
      |         ^~~~~
main.c:69:9: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:73:17: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   73 |                 printf("%d\n", dice.num[3]);
      |                 ^~~~~~
main.c:73:17: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:73:17: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:73:17: note: include '<stdio.h>' or provide a declaration of 'printf'