Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need help making a simple program!

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I need to make the following program (i dont know how).

Read a 2 digit decimal number and display the 2 diged hexadecimal equivalent. (this program neets to be in C++)
 
Hi
hey this isn't some assignment is it? ;-)
try this it doesn't get much simpler
no error detection or anything...
hint don't enter a char just numbers if
you do you may have to control c out of it!

// dec to hex la very basic!
// Robert Dwyer
// use BC++ 5 as DOS or easywin

# include <iostream.h>
# include <iomanip.h>

void main(){

int theinput1;
int theinput2;
int blat;

cout << &quot;Enter the first number -> &quot;;
cin >> theinput1;
cout << &quot;Enter the second number -> &quot;;
cin >> theinput2;

cout << &quot;The Numbers as hex &quot; << endl;
cout << &quot; First -> &quot; << hex << theinput1 << endl;
cout << &quot;Second -> &quot; << hex << theinput2 << endl;

cout << &quot;Enter Key to Exit&quot;;
cin.ignore(128,'\n');
blat = cin.get();

}

enjoy!

HTH [sig]<p>Robert Dwyer<br><a href=mailto:rdwyer@orion-online.com.au>rdwyer@orion-online.com.au</a><br>[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top