Question

Write a c program for binary addition of two 8 bit numbers.

30 Nov 2017
Answer :
Word Count : 336

Here is a C program that performs the binary addition of two 8-bit numbers:

```c
#include <stdio.h>

int main() {
    unsigned char num1, num2, sum;
    unsigned char carry = 0;
    
    // Input two 8-bit numbers
    printf("Enter the first 8-bit number (0-255): ");
    scanf("%hhu", &num1);
    printf("Enter the second 8-bit number (0-255): ");
    scanf("%hhu", &num2);
    
    // Perform binary addition bit by bit
    for(int i = 0; i < 8; i++) {
        // Check the current bit of both numbers and the carry
        unsigned char bit1 = (num1 >> i) & 1;

_________ ___ __________ _________ ______ _______ _________ __________ ___.
______ ___ ________ _______ _______ _________ ________.
_____ __________ ____ _______ __________.
________ _______ _____ _______ _______ ____ __________ ______ _________ _____ __________.
_______ ________ _______ ____ ____ ___ ____.
__________ ________ _____ ________ ________ ___ ________ ___.
_________ ___ _______ _________ _________.
____ _______ ____ _______ __________ ___ ___ ____.
________ ______ ________ ______ ______.
_______ ________ ___ ________ ____ ________.
_____ __________ ____ ______ _________ ________ _______.
__________ ____ ________ _____ ________ _______ ________ ________ ___ ________ _____.
___ ___ _______ _________ _______ ___ ________ _________ __________ ________ ________ ______.
_________ ____ ___ __________ _____ ________ _______ ___ _______ ____.
__________ ______ __________ ___ ________ _______ ____ ____ _____.
_____ _______ _______ _______ _______ _________ ___.
______ ___ ______ ______ ______ __________ __________ ____ _____ _____ ______.
_____ ___ __________ _____ __________ ______ ______ __________ ____ ______.
__________ ___ ____ __________ _________ ________ ____ ___ __________ ___ __________.
___ ______ _____ _____ __________ __________ _____ _____.
___ ______ ________ ________ _________ ______ ______ ____ ___ ________ ________.
______ _______ ______ ______ ______ ____ ____ _______ __________ __________ ________.
________ ______ ___ ________ __________ ____ ______ ____ _______ ___.
______ ________ _______.
IGNOU ACADEMY
Your IGNOU journey, made easier.
  • Solved Assignments
  • Study Notes
  • Guess Papers
  • Question Papers
Skip in 10
Top
📞
Call Support Instant phone assistance IGNOU MCS 11 2010 - Write a c program for binary addition of two 8 bit numbers. | IGNOU Academy
→
🟢
WhatsApp Chat Fast live messaging
→
Email Us Business enquiries & support
→