Answered step by step
Verified Expert Solution
Question
1 Approved Answer
If someone can please help me out with this. I need something to compare it to my code. Prog1: Multi-base input to binary output w/
If someone can please help me out with this. I need something to compare it to my code.
Prog1: Multi-base input to binary output w/ fancy input file (CS220-02, 05) Develop a C (or C++) program that reads an unsigned number in some base and outputs the equivalent value in BCD. Please use only a single source file so I can more easily script the downloading and compiling of your submissions. Your program must require a single command line argument, the name of an input file. This input file will consist of any number of lines, each falling into one of three varieties: 1. Comment - These lines always start with an at-symbot ('@') and should be completely ignored. 2. Blank line - Used to visually organize the input file and should be completely ignored. 3. Data line - These are the ones your program will process and are described below. Data lines will all have exactly two items separated by a single space character: 1. an input base (2 through 16) and 2. an input value in that base whose decimal equivalent will never be more than 6 digits For each Data line from the input file, you must output: 1. the line number of the input file this data line is on (starting the file with line 1... same as a text editor would show) 2. a colon followed by a space 3. the BCD equivalent of the input value, four bits at a time with one space between each set of bits. Remember the decimal values will not exceed 6 digits, so the BCD value will never exceed 24 bits, not including whitespace between 4-bit sets. NEVER print any leading bit sets that contain only zeros... a. eg, instead of 0000 0101 0000 1000, you would print 0101 0000 1000 b. only exception is if the value itself is zero, as in the example below Example input file Expected output to console @ a first example 2: 0101 0110 4: 0010 0100 5: 0000 6: 0100 0011 9: 0001 0010 0011 0100 0101 0110 11 8 70 2 011000 70 @ this is long 10 123456 Your output must precisely match the instructor's so test carefully against the examplesStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started