1
0
Fork 0
This repository has been archived on 2021-11-03. You can view files and clone it, but cannot push or open issues or pull requests.
uni-m.cds-adv-prog/ex5.1/readfromstdin.cpp
Eric Teunis de Boone a54f03b178 Ex5: Input Streams
2019-12-17 18:05:47 +01:00

43 lines
1.2 KiB
C++

#include <iostream>
#include <iomanip>
int main() {
int input = 0;
std::cout << "Give me an Integer in hex: ";
std::cin >> std::hex >> input ;
std::cout << "Dec: " << input << std::endl;
std::cout << "Hex: " ;
std::cout << std::hex << input << std::endl;
std::cout << "Octal: " ;
std::cout << std::oct << input << std::endl;
float f1, f2, f3 ;
std::cout << "Give me three floats: " << std::endl;
std::cout << "f1: " ;
std::cin >> f1 ;
std::cout << "f2: " ;
std::cin >> f2 ;
std::cout << "f3: " ;
std::cin >> f3 ;
std::cout << "The following floats were given: " << std::endl;
std::cout << std::scientific << f1 << " " << f2 << " " << f3 << std::endl;
std::cout << "That is 20 chars columns per float: " << std::endl;
std::cout << std::setw(20) << "ValueA" << " " << std::setw(20) << "ValueB" << " "<< std::setw(20) << "ValueC" << std::endl;
std::cout << std::setfill('-') << std::setw(3*20 + 2 + 1) << " " << std::endl ;
std::cout << std::setfill(' ') << std::setw(20) << std::scientific << f1 << " " << std::setw(20) << f2 << " "<< std::setw(20) << f3 << std::endl;
std::cout << "With 3 digit precision: " << std::endl;
std::cout << std::left << std::setprecision(3) << std::scientific << f1 << " " << f2 << " " << f3 << std::endl;
}