Introducing C



C is a general-purpose programming language that has been around for nearly 50 years.
C has been used to write everything from operating systems (including Windows and many others) to complex programs like the Python interpreter, Git, Oracle database, and more.
The versatility of C is by design. It is a low-level language that relates closely to the way machines work while still being easy to learn.

Hello World!



As when learning any new language, the place to start is with the classic "Hello World!" program
#include <stdio.h>

int main() {
printf("Hello, World!\n");
return 0;
}
Let's break down the code to understand each line:
#include <stdio.h> The function used for generating output is defined in stdio.h. In order to use the printf function, we need to first include the required file, also called a header file.

int main() The main() function is the entry point to a program. Curly brackets { } indicate the beginning and end of a function (also called a code block). The statements inside the brackets determine what the function does when executed.

Data Types



C supports the following basic data types:
int: integer, a whole number.
float: floating point, a number with a fractional part.
double: double-precision floating point value.
char: single character.

The amount of storage required for each of these types varies by platform.
C has a built-in sizeof operator that gives the memory requirements for a particular data type.
For example:
#include <stdio.h>

int main() {
printf("int: %d \n", sizeof(int));
printf("float: %d \n", sizeof(float));
printf("double: %d \n", sizeof(double));
printf("char: %d \n", sizeof(char));

return 0;
}


Comments