Code:
#include<stdio.h>
int convert(char *note);
int main(void){
char note[40][40];
\\static int array[12];
int dArray[12][12];
int i, j;
for(i=0;i<12;i++)
{
printf("Please enter note %d in the series:",i+1);
scanf("%s",note[i]);
dArray[i][0]=convert(note[i]);
}
printf("\n\t");
for(i=0;i<=11;i++)
{
printf("%d\n\t",dArray[i][0]);
}
for(i=0;i<=10;i++)
{
dArray[0][i+1]=(((dArray[0][i]+(dArray[i][0]-dArray[i+1][0])+12)%12));
}
for(i=1;i<=11;i++)
{
for(j=1;j<=11;j++) dArray[i][j]=(dArray[i][j-1] + (dArray[i-1][j]-dArray[i-1][j-1])+12)%12;
}
printf("\n***** Equivalent Serial Matrix *****\n");
for(j=0;j<12;j++)
{
printf("\n");
for(i=0; i<12; i++)
printf("%d ",dArray[i][j]);
}
printf("\n");
}
int convert(char *note){
if( strcmp(note,"C") == 0 || strcmp( note, "c")==0 ||strcmp( note, "B#" ) == 0 || strcmp( note, "b#")==0)
return 0;
else if( strcmp( note, "C#" ) == 0 || strcmp( note, "c#")==0||strcmp( note, "Db" ) == 0 || strcmp( note, "db")==0 )
return 1;
else if( strcmp( note, "D" ) == 0 || strcmp( note, "d")==0)
return 2;
else if( strcmp( note, "D#" ) == 0 || strcmp( note, "d#")==0||strcmp( note, "Eb" ) == 0 || strcmp( note, "eb")==0 )
return 3;
else if( strcmp( note, "E" ) == 0 || strcmp( note, "e")==0||strcmp( note, "Fb" ) == 0 || strcmp( note, "fb")==0 )
return 4;
else if( strcmp( note, "F" ) == 0 || strcmp( note, "f")==0||strcmp( note, "E#" ) == 0 || strcmp( note, "e#")==0 )
return 5;
else if( strcmp( note, "F#" ) == 0 || strcmp( note, "f#")==0||strcmp( note, "Gb" ) == 0 || strcmp( note, "gb")==0 )
return 6;
else if( strcmp( note, "G" ) == 0 || strcmp( note, "g")==0 )
return 7;
else if( strcmp( note, "G#" ) == 0 || strcmp( note, "g#")==0||strcmp( note, "Ab" ) == 0 || strcmp( note, "ab")==0 )
return 8;
else if( strcmp( note, "A" ) == 0 || strcmp( note, "a")==0 )
return 9;
else if( strcmp( note, "A#" ) == 0 || strcmp( note, "a#")==0||strcmp( note, "Bb" ) == 0 || strcmp( note, "bb")==0 )
return 10;
else if( strcmp( note, "B" ) == 0 || strcmp( note, "b")==0||strcmp( note, "Cb" ) == 0 || strcmp( note, "cb")==0 )
return 11;
else
{
printf("Not a Vaild Entry!!!\n");
printf("Please enter note AGAIN:");
scanf("%s",note);
convert(note);
}
}