Flashcards
Language Basics Flashcards
Cards in this deck (11)
- 1How do you access a function/class in the Standard Library?By using the "std" namespace followed by two semi-colons "::"
- 2As a good rule of thumb, how should you gain input from the user?By using "std::getline( cin, std::string var);"
(to be noted that the input it saved as a string in the var) - 3Convert n into its numerical value given: #include #include // Allows for use of strings std::string n; int num; std::cout<<"Enter a #"<< std::endl; std::getline(std::cin, n);#include
#include // Allows use of strings
#include //"stringstream"
std::string n;
int num;
std::cout<<"Enter a #"<< std::endl;
std::getline(std::cin, n);
std::stringstream(n) >> num; - 4How do you get the size of a type & what will it be measured in?sizeof(var); // returns size in bytes (8 bits)
- 5Void is an incomplete type, as a result what may be disallowed?Objects, arrays & references
- 6What are the differences between signed & unsigned types?unsigned types are 2x as big, in value range, but ignore the sign.
(Range: [0, 2x]) - 7How would you resize an int?precede it with "__type n"
(where n = the # of Bytes)
or
use types "short" to shrink & "long" to expand - 8what is the range of values an int (__int32) may hold?[ -2,147,483,648 , +2,147,483,648 ]
- 9List the floating point types from least to most accurate:float, double, long double
- 10What is the size of int, long & pointer in 32-bit Systems?int is 16 bits, while long & pointer are 32 bits.
or
int, long & pointer are 32 bits - 11What is the size of int, long & pointer in 64-bit Systems?int & long are 32 bits, while pointer is 64 bits.
or
int is 32 bits, while long & pointer are 64 bits
Information
- Description
- Includes control io, safer forms of input, type sizing & ranges.
- Created by
- Oscar Rojas
- Views
- 9
- Rating