+ 1
Why Answe is 4
#include <stdio.h> int main() { int x; x = sizeof(int); printf("%d",x); return (0); }
19 Respuestas
+ 2
It will return the size of int and size of int depend on system
+ 2
Yes, because size of int differs compiler to compiler. In most of the books and 16 bit systems , the size of int is 2 bytes. And now in modern 32 bit systems , the size of int have become 4 bytes.
+ 1
Hi remove those irrelevant links please
+ 1
Thanku Tannu Sharma coffeeunderrun
+ 1
In 32 bit system int is 4 bytes
+ 1
Sizeof keyword is present in C to check the datatype storage.It usage in program print the storage in bytes.so here int has storage of 4 bytes
0
But int datatype is of 2 byte
0
Tannu Sharma int = 2 bytes, float = 4 bytes , char = 1 byte
0
Tannu Sharma Means you wants to say int datatype has both 2 bytes and 4 bytes storage
0
Tannu Sharma Actually it depends on the compiler. Every compiler has it's own rules for such things. Here, the sololearn compiler has size of int data type as 4 bytes.
0
Range of int data type is 2 or 4 bytes.
0
because the size of an int is 4 bytes , it’s much better if it was written like that
Printf("%d bytes ",x);
0
برامج كريستينا By system means
0
For eg in embedded programming, if you are using 32bit controller then the int is 4bytes or if it is 16bit controller then it is 2bytes.
0
Okk thanks Satheesh Kumar
0
Thanku برامج كريستينا
0
But on top of system as some people are saying, it really depends on the compiler. It's upto a compiler's mechanism that has to take int as 2 or 4 bytes, regardless of the system.
0
****Look at following Programms you will get better Idea.****
#include<stdio.h>
int main()
{
int a;
char ch;
float m;
double n;
long d;
short b;
printf("\nSize of integer is:%d", sizeof (a));
printf("\nSize of character is:%d", sizeof (ch));
printf("\nSize of float value is:%d", sizeof (m));
printf("\nSize of double value is:%d", sizeof (n));
printf("\nSize of long integer is:%d", sizeof (d));
printf("\nSize of short integer is:%d", sizeof (b));
return 0;
}
**OUTPUT**
Size of integer is:4
Size of character is:1
Size of float value is:4
Size of double value is:8
Size of long integer is:8
Size of short integer is:2