C Saved Program: peaceful-palace

facebook share

Here's the online compiler accompanied with IDE at your service. This is a saved code by one of our users. Try it out or save your own from the IDE page and don't forget to leave a feedback. You can find that at the bottom of the page.


#include<stdio.h>
int main()
{
    int array[12];
   int i;
   int num1,num2,num3,num4,key;
   printf("enter the elements of array");
   for(i=0;i<=12;i++)
   {
       scanf("%d", &array[i]);
   }
   num1=(int)array[0]*4+array[1]*2+array[2]*1;
   switch(num1)
   {
       case 0:
       num1=7;
       printf("%d\n", num1);
       break;
       case 1:
       num1=3;
       printf("%d\n", num1);
       break;
       case 2:
       num1=6;
       printf("%d\n", num1);
       break;
       case 3:
       num1=1;
       printf("%d\n", num1);
       break;
       case 4:
       num1=4;
       printf("%d\n", num1);
       break;
       case 5:
       num1=5;
       printf("%d\n", num1);
       break;
       case 6:
       num1=2;
       printf("%d\n", num1);
       break;
       case 7:
       num1=8;
       printf("%d\n", num1);
       break;
       
   }
    num2=(int)array[3]*4+array[4]*2+array[5]*1;
   switch(num2)
   {
       case 0:
       num2=7;
       printf("%d\n", num2);
       break;
       case 1:
       num2=3;
       printf("%d\n", num2);
       break;
       case 2:
       num2=6;
       printf("%d\n", num2);
       break;
       case 3:
       num2=1;
       printf("%d\n", num2);
       break;
       case 4:
       num2=4;
       printf("%d\n", num2);
       break;
       case 5:
       num2=5;
       printf("%d\n", num2);
       break;
       case 6:
       num2=2;
       printf("%d\n", num2);
       break;
       case 7:
       num2=8;
       printf("%d\n", num2);
       break;
       
   }
    num3=(int)array[6]*4+array[7]*2+array[8]*1;
   switch(num3)
   {
       case 0:
       num3=7;
       printf("%d\n", num3);
       break;
       case 1:
       num3=3;
       printf("%d\n", num3);
       break;
       case 2:
       num3=6;
       printf("%d\n", num3);
       break;
       case 3:
       num3=1;
       printf("%d\n", num3);
       break;
       case 4:
       num3=4;
       printf("%d\n", num3);
       break;
       case 5:
       num3=5;
       printf("%d\n", num3);
       break;
       case 6:
       num3=2;
       printf("%d\n", num3);
       break;
       case 7:
       num3=8;
       printf("%d\n", num3);
       break;
       
   } 
   num4=(int)array[9]*4+array[10]*2+array[11]*1;
   switch(num4)
   {
       case 0:
       num4=7;
       printf("%d\n", num4);
       break;
       case 1:
       num4=3;
       printf("%d\n", num4);
       break;
       case 2:
       num4=6;
       printf("%d\n", num4);
       break;
       case 3:
       num4=1;
       printf("%d\n", num4);
       break;
       case 4:
       num4=4;
       printf("%d\n", num4);
       break;
       case 5:
       num4=5;
       printf("%d\n", num4);
       break;
       case 6:
       num4=2;
       printf("%d\n", num4);
       break;
       case 7:
       num4=8;
       printf("%d\n", num4);
       break;
       
   }
   key=(int)1000*num1+100*num2+10*num3+1*num4;
   printf("\n%d", key);
    
    
}
Execute

Output

Press the execute button or CTRL + enter to run code.

Inputs