Jump to content

Very simple C++ question.. (Binary > Decimal)


Recommended Posts

So I need to write a simple program that takes the user input (int) (Which will be in binary) , and outputs the decimal equivalent.

All we have learned so far is printf, scanf_s, if, do, while, int, and all the math functions.

We're suppose to do this WITHOUT the use of arrays, and WITH a loop.

I have no clue how to do this without arrays.. I know how to convert from binary to decimal and back on paper, but I don't know how to make the computer do this..

Any help would be greatly appreciated!

#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{
int binary, number;
printf("Enter binary number: ");
scanf_s("%d", &binary);

while ()
{
	????????????
}

printf("Decimal equivalent is: %d", decimal);

       return(0);
}

EDIT: Steve, or any admins, if you see this, could we please change the BG color for code blocks? lol

Edited by TLEJ
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Who's Online   0 Members, 0 Anonymous, 883 Guests (See full list)

    • There are no registered users currently online
×
×
  • Create New...