Advertisement
carsit

Untitled

Aug 30th, 2014
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #include <iostream>
  2. #include <bitset>
  3.  
  4. using namespace std;
  5.  
  6. int main(void)
  7. {
  8. int a;
  9. char b;
  10. int operazione;
  11. do {
  12. cout << "Inserire un numero: ";
  13. cin >> a;
  14. cout << "\n1) Conversione binario \n2)conversione ottale \n3)conversione esadecimale \n4)Conversione decimale\nQuale conversione devo fare? ";
  15. cin >> operazione;
  16. switch (operazione){
  17. case 1:
  18. cout <<"\n\nValore binario: "<< bitset<32>(a)<< endl;
  19. break;
  20. case 2:
  21. cout << "Valore ottale: " << oct << a << endl;
  22. break;
  23. case 3:
  24. cout << "Valore esadecimale: " << hex << a << endl;
  25. break;
  26. case 4:
  27. cout << "Valore decimale: " << dec << a << endl;
  28. break;
  29. default:
  30. cout <<"ERRORE";
  31. break;
  32. }
  33. cout << "\nVuoi continuare? (S/N) ";
  34. cin >> b;
  35. }while (b != 'N');
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement