In your terminal, write gedit filename.c
# include <stdio.h>
int main() {
printf("Hello world");
printf("test");
return 0;
}
After writing the code in the text editor, use ctrl + z
to exit gedit.
Use gcc -o build filename.c
To run use ./build
<aside> 💡 Here because we are first time we are executing the code therefore Build and Run both are required. Build actually asks the compiler to build the machine code for the source code we had written. And Run simply runs the code and produce the output.
</aside>
#include <stdio.h>
int main()
{
printf("Size of short int is %ld bytes\\n", sizeof(short int));//2
printf("Size of int is %ld bytes\\n", sizeof(int));//4
printf("Size of long int is %ld bytes\\n", sizeof(long int));
printf("Size of float is %ld bytes\\n", sizeof(float));
printf("Size of double is %ld bytes\\n", sizeof(double));
printf("Size of long double is %ld bytes\\n", sizeof(long double));
printf("Size of char is %ld bytes\\n", sizeof(char));
return 0;
}
%ld
is the placeholder for this variable that simply says take the next argument from the printf
Range of 4 bit data?
Therefore, for 4 byte integer:
4 * 8 = 32 bits