+ 1
Learning C-languge gotten something strange with the use of double float and size of number "4" was gotten how
{... printf("int: %d \n" , sizeof(int))
3 odpowiedzi
+ 3
Not clear question but let me try .
Nothing is strange 🙌 in this
sizeof() operator return size of memory allocated for it's operand in bytes.
Check out:
https://www.geeksforgeeks.org/sizeof-operator-c/
You can pass variables or datatypes as parameter in it.
In c variables of different datatypes require some memory as follows :
char =>1bytes
int => 4 bytes
float => 4 bytes
double =>8 bytes
You have written
printf("int: %d\n",sizeof(int));
so here sizeof(); operator returns an integer 4 which is number of bytes required to store an integer variable in bytes so output is 4.
Thank you.
+ 4
char double int float are not memory sizes!
I said "they are data -types "
*A whole number is int
Any single charecter is called char
*Charecter are any of following =>
Alphabets => 'a' to 'b' ,'A' to 'Z'
Digits => '0' to '9'
Special symbols =>()?='?!/!#:&_%{}[]|\~ etc
Float=> numbes having decimal points or floating points like 3.14 ,5.45,5.0 are floats
So computer requires different amount of memory space to store these data types and I have told you how much it requires for each type but still it's platform dependent.=)
For now remember that char, float, double, int are datatypes and sizeof() tells us how much memory space they require .
+ 1
Okay understood so (char double etc) are memory size in bytes
And please tell me more of what i need to know on C because i just started it sir