/* Seven Segment Indicators (15 pt) Seven segment indicators are commonly used to display numbers 0-9. Using an ASCII approximation the numbers can be represented as: _ _ _ _ _ _ _ _ | | | _| _| |_| |_ |_ | |_| |_| |_| | |_ _| | _| |_| | |_| _| Write a complete C program that generates two random numbers in the range [0 .. 9] and prints them on the screen side by side using an ASCII encoding of their seven-segment indicator representaion (as shown in the sample runs given below). The program must come up with a different pair of numbers every time you run it. It is OK if during some (but not all) runs the two random numbers are the same. SAMPLE RUN #1: _ _ _| | |_ | SAMPLE RUN #2: _ _ |_| _| |_| _| SAMPLE RUN #3: _ |_| |_| _| | */ #include #include #include #define DEBUG 0 int main() { char number[10][3][3]= { /* 0 */ {{' ', '_', ' '}, {'|', ' ', '|'}, {'|', '_', '|'}}, /* 1 */ {{' ', ' ', ' '}, {' ', ' ', '|'}, {' ', ' ', '|'}}, /* 2 */ {{' ', '_', ' '}, {' ', '_', '|'}, {'|', '_', ' '}}, /* 3 */ {{' ', '_', ' '}, {' ', '_', '|'}, {' ', '_', '|'}}, /* 4 */ {{' ', ' ', ' '}, {'|', '_', '|'}, {' ', ' ', '|'}}, /* 5 */ {{' ', '_', ' '}, {'|', '_', ' '}, {' ', '_', '|'}}, /* 6 */ {{' ', '_', ' '}, {'|', '_', ' '}, {'|', '_', '|'}}, /* 7 */ {{' ', '_', ' '}, {' ', ' ', '|'}, {' ', ' ', '|'}}, /* 8 */ {{' ', '_', ' '}, {'|', '_', '|'}, {'|', '_', '|'}}, /* 9 */ {{' ', '_', ' '}, {'|', '_', '|'}, {' ', '_', '|'}} }; int i,j,k; int n1, n2; srand ( time(NULL) ); // initialize the random number generator n1 = rand()%10; // generate a random number [0..9] n2 = rand()%10; // generate a second random number // print the two side by side for(i=0; i<3; i++) { for(j=0; j<3; j++) printf("%c", number[n1][i][j]); printf(" "); for(j=0; j<3; j++) printf("%c", number[n2][i][j]); printf("\n"); } printf("\n"); system("pause"); }