1) Base of hexadecimal number system? Answer : 16 2) Universal gate in digital logic? Answer : NAND 3) Memory type that is non-volatile? Answer : ROM 4) Basic building block of digital circuits? Answer : Gate 5) Device used for data storage in sequential circuits? Answer : Flip-flop 6) Architecture with shared memory for instructions and data? Answer : von Neumann 7) The smallest unit of data in computing? Answer : Bit 8) Unit that performs arithmetic operations in a CPU? Answer : ALU 9) Memory faster than main memory but smaller in size? Answer : Cache 10) System cycle that includes fetch, decode, and execute? Answer : Instruction 11) Type of circuit where output depends on present input only? Answer : Combinational 12) The binary equivalent of decimal 10? Answer : 1010 13) Memory used for high-speed temporary storage in a CPU? Answer : Register 14) Method of representing negative numbers in binary? Answer : Two's complement 15) Gate that inverts its input signal? Answer : NOT 16)...
C program to check if a number is binary or not
int isBinary(int num) {
while (num != 0) {
if (num % 10 > 1) {
return 0;
}
num /= 10;
}
return 1;
}
int main() {
int num;
printf("Enter a number: ");
scanf("%d", &num);
if (isBinary(num)) {
printf("%d is a binary number.\n", num);
} else {
printf("%d is not a binary number.\n", num);
}
return 0;
}
Explanation :
This program defines a function isBinary that takes an integer num as input and returns 1 if num is a binary number, and 0 otherwise. The function checks each digit of the number by dividing it by 10 and checking if the remainder is greater than 1. If any digit is greater than 1, the function returns 0, indicating that num is not a binary number. If all digits are less than or equal to 1, the function returns 1, indicating that num is a binary number.
In the main function, the program prompts the user to enter a number and then calls the isBinary function to check if the number is binary. Depending on the result, the program prints a message to the console indicating whether the number is binary or not.
Sample output:
Here's an example output of the program for the input of the number 10101010:
Enter a number: 10101010
10101010 is a binary number.
And here's an example output of the program for the input of the number 1234:
Enter a number: 1234
1234 is not a binary number.