Instructions
Please read the following instructions carefully before solving & submitting assignment: It should be clear that your assignment will not get any credit (zero marks) if:
Uploading instructions For clarity and simplicity, You are required to Upload/Submit only ONE .CPP file. Note: Use ONLY Dev-C++ IDE. The objective of this assignment is
For any query about the assignment, contact at cs301@vu.edu.pk GOOD LUCK |
|
Marks: 20 |
|
In digital computers, bit patterns are used to represent many types of data. Computers perform various operations on bit patterns. With a good representation scheme, bit patterns represent data and bit pattern manipulations represent operations on data. An important example of this is the Binary Addition Algorithm, where two bit patterns representing two integers, which are manipulated to create a third pattern which represents the sum of the integers.
Most processor chips implement the Binary Addition Algorithm in its silicon as part of their arithmetic logic unit. Write a program in C++ which asks user to enter two binary numbers. Store these two numbers in two different stack variables (objects) bit by bit and calculate its sum and store it in another stack variable and display its sum. Solution Guidelines: 1. Create a class named Bin_add (means stack class) that should contain following inline functions:
2. In main function: (a). Create three objects b1, b2, b_sum of type Bin_add class, two for input and one for storing the sum. (b). Read two binary numbers from user bit by bit and push (insert) them in b1 and b2. (c). Call the Add() function with b_sum object to add and display the sum of both binary numbers. Sample Output 1: Sample Output 2:
|
Check Also
MGT503 GDB 02 Fall 2013 Idea solution
Total Marks 10 Starting Date Monday, January 20, 2014 Closing Date Wednesday, January 22, 2014 …