Knowee
Questions
Features
Study Tools

Which of the following gives the size of a 'long' type variable in bytes?18236

Question

Which of the following gives the size of a 'long' type variable in bytes?18236

🧐 Not the exact question you are looking for?Go ask a question

Solution

The size of a 'long' type variable in bytes can vary depending on the system and compiler, but typically, it is 8 bytes on a 64-bit system and 4 bytes on a 32-bit system. However, you can always check it using the sizeof operator in C/C++. Here is how you can do it:

  1. First, you need to include the stdio.h header file in your C/C++ program. This header file contains declarations of functions and macros for performing input and output operations in your program.
#include<stdio.h>
  1. Next, in the main function of your program, you can use the sizeof operator to get the size of a 'long' type variable. The sizeof operator is a compile-time unary operator that can be used to compute the size of its operand.
int main() {
    long int variable;
    printf("Size of long int : %ld bytes", sizeof(variable));
    return 0;
}
  1. When you run this program, it will print the size of a 'long' type variable in bytes.

Please note that the number 18236 you provided does not relate to the size of a 'long' type variable in bytes.

This problem has been solved

Similar Questions

VariablesWhat is the size of an int data type?Options8 bytesDepends on the system or compiler2 bytes4 bytes

On a 32-bit Linux system, what is the size of a long?(a) 2 bytes(b) 4 bytes(c) 6 bytes(d) 8 bytes(e) 16 bytes

What is the size of the char data type in bytes?A. 1 byteB. 2 bytesC. 4 bytesD. It depends on the system

In C, long int data type occupies 4 bytes (32 bits) of memory to store an integer value.long int (or) signed long int data type denotes a 32-bit signed integer that can hold any value between -2,147,483,648 (-231) and 2,147,483,647 (231-1).unsigned long int data type denotes a 32-bit integer.It does not use a bit to store the sign. Hence, it can hold only positive values between 0 and 4,294,967,295 (232-1).long is used whenever an int data type is not sufficient to represent a number.Consider the following example that uses long int data type:#include <stdio.h>void main() { long int num1 = 12345676L; long int num2 = 23L; long int total; total = num1 + num2; printf("Total of the given two numbers = %ld\n", total);}Here, 4 bytes of memory is allocated to each variable num1, num2 and they are initialized with long literals 12345676L and 23L respectively.As you can notice, the long literal values are suffixed with char 'L' (lowercase of 'L' can also be used, however the uppercase is more readable)If any variable is not initialized, then the local variable contains garbage value (i.e., some preexisting value in the allocated memory which may not make sense) by default. Some compilers like gcc automatically initialize the uninitialized int variables to zero.Click on Live Demo to learn about long int data type in C.Select all the correct statements from the given statements.The max value of a long is twice the max value of an intA long can also represent decimal (fractional) numbers.A long literal value can be enclosed within single or double quotes.A long literal value can be a negative or a positive number within the range of -231 and 231-1.

werWhat is the size of int variable?Options8 bit32 bit16 bit64 bit

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.