C++ :: User To Enter Decimal Value Then Display Its Corresponding Binary Numbers

Sep 13, 2013

Create a program that will ask the user to enter a decimal value (1-999999) then display its corresponding binary numbers. Repeat this process until the value entered is equal to 0. Use the following Function Prototype:

void BinCodes(int value);
Sample Input/Output:
Enter a Decimal: 35
Binary: 100011
Enter a Decimal: 184
Binary: 10111000
Enter a Decimal: 0

View 4 Replies


ADVERTISEMENT

C :: Binary To Decimal Conversion Through A Port To Display On LCD Display

Dec 6, 2013

I know this is more simple than I am making it out to be. I have a solar panel hooked up to an 8-Bit ADC and linked into my Microprocessor. I am trying to take the Binary readout from the ADC and convert it to a decimal number to be displayed on the boards LCD display. I am wiring the ADC to PORTA on my Motorola Freescale Board. This is for a final project for my electronic systems class due on Monday...

View 3 Replies View Related

C :: Convert Binary Numbers To Decimal

Mar 27, 2013

The code should convert binary numbers to decimal but it doesn't..

Code:
#include <stdio.h>
#include <math.h>
#include <string.h>
int main()
{

[Code] ....

View 4 Replies View Related

C++ :: Converting Binary Numbers Into Decimal

Apr 25, 2014

This is the question: [URL] .....

Now I have the binary numbers printed out in my code, but I don't know how I can covert them into to decimal.

#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;
int main() {
int numberOfDigits;
int numberOfRows;
char flag;

[Code] ....

View 1 Replies View Related

Visual C++ :: Converting Decimal Number Given By User To Binary?

Dec 19, 2014

Write a C++ program that adds three binary numbers of 8-bit each. Every number is stored into an array of 8 elements.

Example:

Array A
0 1 2 3 4 5 6 7
0 1 1 0 1 1 1 0
+
Array B
0 1 2 3 4 5 6 7
0 1 1 0 1 1 1 0
+
Array C
0 1 2 3 4 5 6 7
0 1 1 0 1 1 1 0

Store the result into an array D of 8 elements. Your program should show the decimal numbers for every binary number. Print screen of 6 answers. This means you should try your program six times with different numbers in every run and show the printed screen result.

View 5 Replies View Related

C++ :: Allow Users To Enter Any Two Positive Numbers And Then Display Results - Arithmetic Operators

May 14, 2013

The Program must allow users to enter any two positive numbers and then display the results.

#include <iostream>
using namespace std;
class ArithmeticOperators{
private:
int x;
int y;
public:
void set_values();

[Code] .....

View 2 Replies View Related

C++ :: Convert List Of Binary Numbers From A File Into Decimal And Print To Screen

Sep 23, 2014

I am trying to make a program that will convert a list of binary numbers from a file into decimal and print the decimal to the screen. I have no problem doing the conversion, the problem comes up when our teacher wants the input file in a format as such:

3
10110101
11111111
10101010

The first number is supposed to tell the program how many different 8bit strings it is going to have to convert, and then the following lines are those binary numbers.

I am not very experienced with file inputs, and I know how to open files and read lines in.. The problem is, how to say "ok the first line says 3, so now I have to convert the next 3 lines" . I am assuming it is just a simple loop that I am missing....

View 4 Replies View Related

C++ :: User To Enter A Word And Convert It To Numbers

Jan 28, 2015

Having problem with my code. i keep getting an error towards the bottom of the code. i need the user to enter a word. and with that word convert it to numbers. once i have convert it if it is bigger than 20 i have to add the two digits together and get print out the array that response to it.

example" ALEX
A=1
L=12
E=5
X=23

1+12+5+23= 41 //since its bigger than 20 you add 4 and 1 together so it will be 5. after that you print the 5th element of array

#include <iomanip>
#include <iostream>
#include <string>
using namespace std;
int main()
{
string name;

[Code]...

View 2 Replies View Related

C++ :: Enter As Many Numbers Until User Doesn't Type E To Exit

Oct 27, 2013

Enter as many numbers as you want as long as the user doesn't type 'e' to exit.

Problem: When I enter a number, it works fine, but if I enter e then it'll go in an infinite loop since the letter is being stored in an int variable. How can I (when I press 'e') make it convert to a char to make it end the program?

#include <iostream>
using namespace std;
int main() {
int num;
cout << "Enter a number or press e to exit:";

[Code] ....

Our class has just started c++ and we have not learned arrays and classes yet, so I'm guessing there is a way to do this without it? Or no?

View 2 Replies View Related

C++ :: Display Numbers In Binary Search Tree - Getting 0s

Jan 31, 2015

I want to display the numbers in a bst but all I get are 0s, what is wrong with my code that is causing this?

#include <iostream>
using namespace std;
class binarySearchTree {
private:
class TreeNode {
friend class binarySearchTree;
int value;

[Code] ....

View 1 Replies View Related

C++ :: For Loop - Display Smallest And Largest Numbers From User Input

Jul 29, 2013

I'm suppose to write a program using (for loop) that asks the user to enter any amount of numbers, so that it can display the smallest and largest. My program successfully finds the largest, but it is always displaying 0 for the smallest, I think Im doing something wrong with the internalization but I dont know what to change it to.

This is what I have ....

#include <iostream>
using namespace std;
int main() {
int amount;
int count;
int number = 0;
int smallest = 0;
int largest = 0;
cout << "Enter total numbers to process: ";

[Code] ....

View 4 Replies View Related

C++ :: Enter Decimal Number Into Program And Required Base

Oct 12, 2013

You enter decimal number into the program and what base you want. The integer part of the decimal is being handled fine, but the decimal is not.

For example, I enter 15.6847 and base 10, which means I'm going from base 10 to base 10. It spits out 68469999999999 for the decimal part. (Do not worry about the first block of numbers. The second block seperated from the first by a space is where the decimal will appear in order.)

#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int baseConverter(int, int, int *, int *);

[Code] ....

View 2 Replies View Related

C :: Finding Written Numbers In A String And Converting Them To Decimal Numbers

Jun 20, 2013

User enters sentence "The Smiths have two daughters, three sons, two cats and one dog." (The numbers may change depending on what the user chooses to enter. He told us the range would be from zero to nine.) and we have to convert the written numbers within the sentence into actual decimal numbers and print out the new sentence. Ex. The Smiths have 2 daughters, 3 sons...etc.

I have written the following bit of code which reads the string and finds all the "written numbers" but I am not sure how to proceed from there. I am stuck on how to print out the new sentence with the converted numbers as my professor mentioned something about creating the new string using dynamic memory allocation.

Code:
#include <stdio.h>#include <string.h>
int main () {
char A[100];
int length = 0;
int i;

[Code] .....

View 7 Replies View Related

C :: Binary Number To Decimal

Mar 30, 2014

I am very new to programming and have been working on a program that can receive decimals or binary numbers and convert them. The decimal --> binary works fine. For some reason I cannot figure out I cannot get the "BinaryToDecimal" function to perform. By putting a "printf" into the for-loop.

Code:

#include <stdio.h>#include <string.h>
#include <math.h>
char* ReverseString (char _result[]) {
int start, end, length = strlen(_result);
char swap;
for (start = 0, end = length-1; start < end; start++, end--)

[code]....

View 2 Replies View Related

C :: Decimal To Binary Using Bitwise

Nov 15, 2013

How to do this program i can easily do it in a simple for loop but i have to do this program with the following directions:

1. Write a function called bitN() that returns the value of bit N in number, where number is the first parameter, and N is the second. Assume N of the least significant bit is zero and that both parameters are unsigned int's. (A simple one-liner will suffice)

2. Write a main() function that uses bitN() to convert a decimal integer into its binary equivalent. Obtain the integer to convert from the first command-line argument.

3. Use the expression
unsigned int numBits = sizeof(unsigned int)*CHAR_BIT;
to get the number of bits in an unsigned int. (Include limits.h to get the definition for CHAR_BIT.)

View 2 Replies View Related

C :: Binary To Decimal Converter

Feb 26, 2013

I'm trying to make a program that takes up to a seven digit binary number and converts it to its decimal equivalent. I'm still a beginner, so this might be a simple question but how do I stop the user from entering anything but 1s and 0s? This means no decimals or numbers other than 1 or 0.I already made it so it won't accept anything below 0 or above 1111111.

View 1 Replies View Related

C :: Decimal To Binary - Error

Aug 24, 2014

I am trying to convert user inputted decimal to binary .

Code:

#include<stdio.h>
main() {
int a,b,c,d[30],i,j,e[30];

[Code].....

View 2 Replies View Related

C++ ::  Binary To Decimal Converter

Mar 15, 2013

#include <iostream>
#include <math.h>
using namespace std;
int main() {
int N=0, counter=0, counter1=0,counter2=0, temp=0, temp1=0,dec=0,result=0, moder=0;

[Code] .....

This is Binary to Decimal Converter. It's not working. Although Dry Run of this program works fine.

View 4 Replies View Related

C++ :: Binary To Decimal Convertor?

May 17, 2014

#include<iostream>
#include<conio.h>
using namespace std;
void main() {
int num1,num2,ans,rem;

[Code] .....

View 6 Replies View Related

C/C++ :: Binary Number Into Decimal?

Sep 10, 2014

I have a code and am asked to modify it so that it will take as input as unsigned binary number up to 16 digits in length and convert it into its equivalent decimal number and output that decimal number.

All I know is that I use library function strlen() in <cstring> to calculate the length of the input string.

I also know I have to use something called pow(2,4);

//pow (); is found in cmath

I was told to use sum = sum >>16-l; (l is the length of />/>

#include <iostream>
using namespace std;
int main() {

[Code]....

View 4 Replies View Related

Visual C++ :: Enter First And Surname And Then Display Full Name

Sep 21, 2012

I'am new to C++, program is : enter first and surname and then display the full name:

code below:

// Enter first and surname and then display the full name.
#include<iostream>
#include<string>
#include<cctype>
using namespace std;

[Code] ....

View 10 Replies View Related

C++ :: Binary To Decimal Conversion Program

Jul 25, 2013

So I tried debugging this program almost 10 times, each time finding a problem then making code to fix it, I used to get wrong values but then now after I changed the calculation from an infinity while loop to a for loop (because after some changes I realized that now I know the number of entries, meaning the start and the end of the loop) the program now displays no values at all. I checked it thoroughly and until the calculation process its functioning exactly the way it should but then the calculation breaks hell loose . Also the for loop that raises 2 to the power needed works fine too so it must be something with the other processes included in the calculation....

This used to be a function of a multiple value types conversion program, I isolated it for easier analysis as a lone standing program.

Code:
#include<iostream>
using namespace std;
int main() {
int d[10],e[10],anse=1,r,limit;
short int counterd=0,i,j;
float bind=0;

[Code] ....

View 11 Replies View Related

C++ :: Convert From Decimal To Binary With Base 2

Dec 7, 2014

I had an exercise to convert from decimal to binary with base 2, it was simple simple i did the following:

Code:
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
void Conversion (int n);

[Code] .....

I then had an follow up exercise which was to replicate but for any base up to 10, i thought i would just have to replace 2 with a variable obtained from the user, however this did not work as i got an error saying too few arguments function but i cannot see why i am getting this.

Code:
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
float Conversion (int n, int b);

[Code] ......

View 5 Replies View Related

C :: Convert Decimal To Binary On Language

Nov 15, 2013

The goal of my program is to convert a decmial number to a binary number.First, the program gets an input to an array of chars, and the function translate_dec_bin converts this array to a decimal number through the strtoul function.The problem is that my program prints the binary number with an additional "0".For exmaple, for the input 1 - the program prints 01 instead of 1, for the input 3 - the program prints 011 instead of 11.

Code:

#include <stdio.h>
#include <stdlib.h>
#define MAX_LEN 20
void translate_dec_bin(char s[]){
char st[sizeof(unsigned)*20] = { 0 };
}

[code]....

View 2 Replies View Related

C :: Decimal To Binary Converter (8-bits)

Sep 9, 2014

I was trying to program an decimal to binary converter (8-bits) in C. I am a complete beginner so I tried to put the 1's and 0's of the binary number as they come without reversing the order for beginning. I have seen example on the internet but didn't understand them so I decided to write it as I understood it. So, I typed the code as shown below:

Code:
#include <stdio.h>
#include <stdlib.h>
int main() {
int number;
int BitNum[8], x;

[Code] ....

The problem with the code is that if binary form has 0s in it then program displays a random number instead of a 0. For example if decimal is 7, it should print out 11100000 but it displays only 111(and some stupid numbers instead of 0). I have tried to solve it but failed.

View 7 Replies View Related

C++ :: Converting Decimal To Binary Using Recursion

Feb 25, 2013

I'm trying to write a program that converts a decimal number to a binary one. I have most of the program written, but I am having a little bit of trouble. Whenever I enter a decimal number, the program will convert it correctly to binary, however, the last number is not included in the conversion. EX: Converting 37 into binary (0100101) yields 010010 when entered into the program. BTW the program must utilize recursion to achieve this goal.

#include <iostream>
using namespace std;
void decToBinary(int num1);
int main() {
int num1;

[code]....

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved