| | |
binary to decimal
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Apr 2009
Posts: 22
Reputation:
Solved Threads: 0
C++ Syntax (Toggle Plain Text)
#include <iostream> #include <fstream> using namespace std; void PrintError(fstream&, char, bool&); int Conversion(fstream&, char&, bool&); int main() { fstream InFile; char Bit; int Decimal; bool BadBit = false; //Open file to read InFile.open("f:\\Binary.txt",ios::in); //Read the first bit of the number InFile.get(Bit); //continue reading all numbers till the end of file while (!InFile.eof()) { //call Conversion to convert binary to decimal Decimal = Conversion(InFile, Bit, BadBit); //check if there is error if (BadBit) { //Print out error message PrintError(InFile, Bit, BadBit); } else //output the equivalent value of decimal cout<<" = " <<Decimal<<endl; //read the next number InFile.get(Bit); } InFile.close(); return 0; } int Conversion(fstream& In, char& InBit, bool& Error) /* Pre: The stream is open for input. InBit is 1 or 0. Error indicates the InBit is not One or Zero. Post: return the conversion of binary to decimal. Resets Error to true when encounter error. */ { } void PrintError(fstream& In, char BadOne, bool& Error) /* Pre: The stream is open for input. BadOne is bad digit. Error indicates the BadOne is bad digit. Post: Prints error message. Resets Error to false means there is no error. */ { }
hey guys can sum1 plsss do dis program for me.....trust me guys i have been doin it from 3 days but m not able to do it.......pls guys i have a submission tmr....thanks a lot
•
•
Join Date: Jan 2008
Posts: 2,052
Reputation:
Solved Threads: 118
Due to lack of freedom of speech, i no longer post on this website.
•
•
Join Date: Apr 2009
Posts: 22
Reputation:
Solved Threads: 0
but its from decimal to binary....... n i really want sum1 to edit n work on d program i have given above....i really dont have time nor do i know how to do it....i tried as much as i could.....plsss sum1 edit my program n post it for me...
output should be as follows
1 = 1
10 = 2
11 = 3
12: Bad number!
10000 = 16
10101 = 21
13: Bad number!
end: Bad number!
output should be as follows
1 = 1
10 = 2
11 = 3
12: Bad number!
10000 = 16
10101 = 21
13: Bad number!
end: Bad number!
![]() |
Similar Threads
- Number System:Conversion from binary to decimal (C)
- binary to decimal in c++ code (C++)
- How do I Take in Hexidecimal input out put binary, decimal, and octal (Java)
- i need code for binary to decimal (it should be written in 'C') (C)
Other Threads in the C++ Forum
- Previous Thread: Adding char to a dynamic array
- Next Thread: Linker error help?
| Thread Tools | Search this Thread |
api array based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






