answersLogoWhite

0


Best Answer

sizeof is your friend.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you find out the size of all the data types in C program?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Why do we have 2 DATA types of same size for integer?

One of them is signed, the other is unsigned.


Which type of data uses the least bandwidth?

Primitive data types are smaller in size and hence are efficient in processing and use the least bandwidth.


How do you change data types range in c?

You can not change the range of a data type. It is a function of the implementation and is dependent on the word size of the implementation's computer hardware.


Write a program in C plus plus to store 100 element within array and find the particular element if exist?

#include<iostream> #include<iomanip> #include<time.h> template<typename T> size_t find(T& data, T a[], size_t size) { size_t index=0; do { if(a[index]==data) break; } while(++index<size); return(index); } template<typename T> void print(T a[], size_t size) { using std::cout; using std::endl; using std::setw; size_t index=0; do{ if(index&&index%20==0) cout<<endl; cout<<setw(3)<<a[index]; }while(++index<size); cout<<endl; } int main() { srand((unsigned)time(NULL)); const size_t size=100; unsigned int a[size]; size_t index=0; do{ unsigned int data=rand()%100; do{ data=rand()%100; } while(find(data,a,index)<index); a[index]=data; } while(++index<size); print(a,size); }


Who decides size of data types in a language?

The people who create the language take the liberty of deciding the size of data types in a programming lanauage.If you (as a programmer) create your own custom data type, for example by defining a class, then you decide what goes into it - for example, in Java, if one of the pieces of data requires an integer, you have the choice of storing it as an int, which uses 4 bytes, or as a long, which uses 8 bytes (and permits larger numbers).

Related questions

A simple program to find the size of different basic data types in C?

you can just use sizeof. sizeof(int) for example


What is the role of heap in the dynamic memory allocation?

memory allocation has two types : static and dynamic 1) the static are for the data types that will never change in size during the program execution suxh as integers (1 and 1000 will take the same size if we declare them to have the same type). 2) while another data types such as arrays and lists , will grow and shrink during execution time (due to the addition and removing) . the HEAP is the part of the memory where such data (in part 2) are allocated.


Why do we have 2 DATA types of same size for integer?

One of them is signed, the other is unsigned.


What is the importance of union in c program?

Importance of union in 'C':unions are the concept borrowed from structures in structures we allow different datatypes in which each datatype is allocated a separate memory location .But in unions same as structures we use different data types but all the datatypes will be allocated to a single memory location and only one datatype with maximum size will be used for allocation of all the data types used in a union program.Sample code for union is as follows:union item {int m;float c;char x;}code;In the above program we used three kinds of datatypes here integer size is 4 so the other data types will be shared in the same location of size 4.then the memory will not be wasted and all the memory will be utilized perfectly.


What are the commonly use data types with their equivalent size in solving the base address of an array?

int


Which type of data uses the least bandwidth?

Primitive data types are smaller in size and hence are efficient in processing and use the least bandwidth.


What are arreys in c?

arrays in C are the data types which have collection of same type of data together store a fixed-size s of elements .


How do you know if your air conditioner is the proper size for the house?

The only way to accurately determine the proper size air conditioner is to perform a load calculation. This is a process that takes into account the construction features of the home. These details along with other information is entered into a computer program. The program finds the heat gain and loss for the structure. With that data you can find the size required.


How do you change data types range in c?

You can not change the range of a data type. It is a function of the implementation and is dependent on the word size of the implementation's computer hardware.


How can you get size of datatype?

like this: sizeof(int); replace int with the kind of data you want to find the size of. of course, to be able to do anything with this size data, you'll have to store it into a variable or display it or something.


What is the importance of union in a c program?

Importance of union in 'C': unions are the concept borrowed from structures in structures we allow different datatypes in which each datatype is allocated a separate memory location .But in unions same as structures we use different data types but all the datatypes will be allocated to a single memory location and only one datatype with maximum size will be used for allocation of all the data types used in a union program.Sample code for union is as follows: union item { int m; float c; char x; }code; In the above program we used three kinds of datatypes here integer size is 4 so the other data types will be shared in the same location of size 4.then the memory will not be wasted and all the memory will be utilized perfectly.


Is it necessary to have same size for all members in an union?

it is not necessary to have same size for all members in an union ..because unions holds different data types..