Home › C and C++ › Visual C++

It looks like you're new here. If you want to get involved, click one of these buttons!

- 141.2K All Categories
- 103.9K Programming Languages
- 6.5K Assembler Developer
- 1.9K Basic
- 40K C and C++
- 2.9K C#
- 7.9K Delphi and Kylix
- 4 Haskell
- 9.7K Java
- 4.1K Pascal
- 1.3K Perl
- 2K PHP
- 553 Python
- 37 Ruby
- 4.4K VB.NET
- 1.6K VBA
- 20.9K Visual Basic
- 2.6K Game programming
- 317 Console programming
- 93 DirectX Game dev
- 1 Minecraft
- 112 Newbie Game Programmers
- 2 Oculus Rift
- 9K Applications
- 1.8K Computer Graphics
- 748 Computer Hardware
- 3.5K Database & SQL
- 535 Electronics development
- 1.6K Matlab
- 628 Sound & Music
- 258 XML Development
- 3.3K Classifieds
- 199 Co-operative Projects
- 199 For sale
- 190 FreeLance Software City
- 1.9K Jobs Available
- 605 Jobs Wanted
- 213 Wanted
- 2.9K Microsoft .NET
- 1.8K ASP.NET
- 1.1K .NET General
- 3.4K Miscellaneous
- 7 Join the Team
- 356 Comments on this site
- 71 Computer Emulators
- 2.1K General programming
- 188 New programming languages
- 641 Off topic board
- 226 Mobile & Wireless
- 98 Android
- 126 Palm Pilot
- 340 Multimedia
- 156 Demo programming
- 184 MP3 programming
- Bash scripts
- 28 Cloud Computing
- 53 FreeBSD
- 1.7K LINUX programming
- 371 MS-DOS
- Shell scripting
- 321 Windows CE & Pocket PC
- 4.1K Windows programming
- 944 Software Development
- 417 Algorithms
- 68 Object Orientation
- 92 Project Management
- 95 Quality & Testing
- 271 Security
- 7.7K WEB-Development
- 1.8K Active Server Pages
- 62 AJAX
- 6 Bootstrap Themes
- 55 CGI Development
- 28 ColdFusion
- 224 Flash development
- 1.4K HTML & WEB-Design
- 1.4K Internet Development
- 2.2K JavaScript
- 37 JQuery
- 310 WEB Servers
- 157 WEB-Services / SOAP

miss a
Member Posts: **4**

in Visual C++

[b][red]This message was edited by miss a at 2002-9-13 4:55:46[/red][/b][hr]

hi all am abegener in VB C++ and i have a problem in solving this program if any one can help me do please.. as soon as possible

this is the problem

It is required to write a C++ program which converts a decimal signed number to its binary equivalent using two’s complement representation of a negative number. Then your program will print the decimal number and its binary equivalent to the screen. After that your program will convert the binary number to its equivalent decimal number using the polynomial representation of the number and print the output to the screen as a decimal number (Read Chapters 2, 3, and from your text book). Your program must be fully documented with your Name, student’s ID, Section number, Course Name, and the Date of submission on the top of the program.

To convert a negative decimal number to its 2's complement, the following algorithm is used.

2’s Complement Algorithm

Convert each bit to its complement

Add 1 to the least significant bit

Remark: Don’t forget that you are performing addition in binary and the carry will be added to the second higher digit until the sign bit.

Output Sample:

Input an integer number 10

Its binary equivalent 0 0 0 0 1 0 1 0

Its Decimal equivalent after calculating its value using polynomial 10

Do you want more activities: y/n ? y

Input an integer number -8

Its binary equivalent in 2’s complement format 1 1 1 1 1 0 0 0

Its Decimal equivalent after calculating its value using polynomial -8

Do you want more activities: y/n ? n

Bye

Programming Assignment: Your program must do the following.

1. Limit your integer number to an 8-bit maximum size with the sign bit. Check the size of each integer. If it is accepted (within the 8-bit register size: 127 for positive and -128 for negative), then go to the next step or inform the user that the number is larger than the size of the machine and ask him to input new number.

2. Convert a positive integer number into binary form using the function: DecimaltoBinary (See the algorithm in your Text book). If the number is negative, then save the sign of the number and convert it to positive so that the function DecimaltoBinary can be used; after the conversion to binary, convert the result to its 2's complement form as shown above using the function: TwosComplement.

4. Print the result of conversion for the decimal number (Use function PrintArray).

5. Check the sign bit of the binary number. If the sign bit is negative, save the sign bit and convert the binary number to positive by taking the 2's complement of the number using the function TwosComplement. Finally, convert the binary number to decimal using the function: BinarytoDeceimal. Print the result of conversion.

6. Ask the user if he/she wants more activity: answer yes/no (your program will be in a loop and it will be terminated only if you say: no).

hi all am abegener in VB C++ and i have a problem in solving this program if any one can help me do please.. as soon as possible

this is the problem

It is required to write a C++ program which converts a decimal signed number to its binary equivalent using two’s complement representation of a negative number. Then your program will print the decimal number and its binary equivalent to the screen. After that your program will convert the binary number to its equivalent decimal number using the polynomial representation of the number and print the output to the screen as a decimal number (Read Chapters 2, 3, and from your text book). Your program must be fully documented with your Name, student’s ID, Section number, Course Name, and the Date of submission on the top of the program.

To convert a negative decimal number to its 2's complement, the following algorithm is used.

2’s Complement Algorithm

Convert each bit to its complement

Add 1 to the least significant bit

Remark: Don’t forget that you are performing addition in binary and the carry will be added to the second higher digit until the sign bit.

Output Sample:

Input an integer number 10

Its binary equivalent 0 0 0 0 1 0 1 0

Its Decimal equivalent after calculating its value using polynomial 10

Do you want more activities: y/n ? y

Input an integer number -8

Its binary equivalent in 2’s complement format 1 1 1 1 1 0 0 0

Its Decimal equivalent after calculating its value using polynomial -8

Do you want more activities: y/n ? n

Bye

Programming Assignment: Your program must do the following.

1. Limit your integer number to an 8-bit maximum size with the sign bit. Check the size of each integer. If it is accepted (within the 8-bit register size: 127 for positive and -128 for negative), then go to the next step or inform the user that the number is larger than the size of the machine and ask him to input new number.

2. Convert a positive integer number into binary form using the function: DecimaltoBinary (See the algorithm in your Text book). If the number is negative, then save the sign of the number and convert it to positive so that the function DecimaltoBinary can be used; after the conversion to binary, convert the result to its 2's complement form as shown above using the function: TwosComplement.

4. Print the result of conversion for the decimal number (Use function PrintArray).

5. Check the sign bit of the binary number. If the sign bit is negative, save the sign bit and convert the binary number to positive by taking the 2's complement of the number using the function TwosComplement. Finally, convert the binary number to decimal using the function: BinarytoDeceimal. Print the result of conversion.

6. Ask the user if he/she wants more activity: answer yes/no (your program will be in a loop and it will be terminated only if you say: no).

Terms of use / Privacy statement / Publisher: Lars Hagelin

Programmers Heaven articles / Programmers Heaven files / Programmers Heaven uploaded content / Programmers Heaven C Sharp ebook / Operated by CommunityHeaven

© 1997-2017 Programmersheaven.com - All rights reserved.

## Comments

0✭_____ ( http://forcoder.org ) free video tutorials and ebooks about ( Perl, PHP, Python, Visual Basic .NET, C++, Assembly, R, PL/SQL, Objective-C, Java, MATLAB, C, C#, Scratch, Visual Basic, Ruby, JavaScript, Go, Delphi, Swift Lua, VBScript, SAS, Alice, Apex, Fortran, Rust, Kotlin, LabVIEW, Dart, Scala, Bash, Ada, Awk, Scheme, ABAP, Erlang, Lisp, Prolog, F#, COBOL, Transact-SQL, Clojure, FoxPro, Julia, Crystal, Logo, ML, Hack, D ) ________