/******************************************************** * Section : 15 * Machine No. : N * Roll No. : 19CS100XY * Name : Aritra Hazra * Assignment No : LT-2-ODD-B * Description : Find Number of Zeros from K1-th position to K2-th position in N-th Row (+ print) ********************************************************/ #include #include #include #include /* recursively searches the k-th symbol present in n-th row expansion */ int kthSymbol(unsigned int n, unsigned long long int k) { if (n == 1) { return 0; } if (k % 2 == 0) { if (kthSymbol(n - 1, k / 2) == 0) { return 1; } else { return 0; } } else { if (kthSymbol(n - 1, (k + 1) / 2) == 0) { return 0; } else { return 1; } } } /* prints the expanded rows */ void printRows(unsigned int n) { unsigned int l; unsigned long long int i, j, rowLength; char *rowStr; rowStr = (char *)malloc(pow(2,n)*sizeof(char)); printf("\n++ The 1-th Row: 0"); rowStr[0] = '0'; rowStr[1] = '1'; rowStr[2] = '\0'; printf("\n++ The 2-th Row: %s", rowStr); for(l=2; l