C++/Data Type/unsigned
Read unsigned int and output it
<source lang="cpp">
- include <iostream>
using namespace std; int main() {
int myInt; long myLong; double myDouble; float myFloat; unsigned int myUnsigned; char myWord[50]; cout << "int: "; cin >> myInt; cout << "Long: "; cin >> myLong; cout << "Double: "; cin >> myDouble; cout << "Float: "; cin >> myFloat; cout << "Word: "; cin >> myWord; cout << "Unsigned: "; cin >> myUnsigned; cout << "\n\nInt:\t" << myInt << endl; cout << "Long:\t" << myLong << endl; cout << "Double:\t" << myDouble << endl; cout << "Float:\t" << myFloat << endl; cout << "Word: \t" << myWord << endl; cout << "Unsigned:\t" << myUnsigned << endl; cout << "\n\nInt, Long, Double, Float, Word, Unsigned: "; cin >> myInt >> myLong >> myDouble; cin >> myFloat >> myWord >> myUnsigned; cout << "\n\nInt:\t" << myInt << endl; cout << "Long:\t" << myLong << endl; cout << "Double:\t" << myDouble << endl; cout << "Float:\t" << myFloat << endl; cout << "Word: \t" << myWord << endl; cout << "Unsigned:\t" << myUnsigned << endl;
return 0;
}
</source>
unsigned int type integer shifts bits
<source lang="cpp">
- include <iostream>
using namespace std; int main(void) {
unsigned int value, one = 1; value = one << 1; cout << "Value: " << value << "\n"; cout << "Result: " << (one << 1) << "\n";
}
</source>