c++ int length
ex: input = 2424, output = 4
static int intlen(int n)
{
if (n == 0) return 1;
else if (n < 0) return 2 + static_cast<std::size_t>(std::log10(-n));
else if (n > 0) return 1 + static_cast<std::size_t>(std::log10(n));
}
c++ int length
ex: input = 2424, output = 4
static int intlen(int n)
{
if (n == 0) return 1;
else if (n < 0) return 2 + static_cast<std::size_t>(std::log10(-n));
else if (n > 0) return 1 + static_cast<std::size_t>(std::log10(n));
}
range of long long in c++
Long
Data Type Size (in bytes) Range
long int 4 -2,147,483,648 to 2,147,483,647
unsigned long int 4 0 to 4,294,967,295
long long int 8 -(2^63) to (2^63)-1
unsigned long long int 8 0 to 18,446,744,073,709,551,615
data types in c++
int myNum = 5; // Integer (whole number)
float myFloatNum = 5.99; // Floating point number
double myDoubleNum = 9.98; // Floating point number
char myLetter = 'D'; // Character
bool myBoolean = true; // Boolean
string myText = "Hello"; // String
c++ length of int
unsigned int number_of_digits = 0;
do {
++number_of_digits;
n /= base;
} while (n);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us