DEV Community

Cover image for Understanding the Building Blocks of C Programming
AP09
AP09

Posted on

Understanding the Building Blocks of C Programming

Before learning about programming in C ,lets understand what does programming means ?
Programming is set of logically grouped instructions given to computer so that it understands it and execute it.
Computers are incredibly fast and accurate, but they have one limitation they cannot decide what task to perform without instructions, programming gives the instruction to the computer to perform some task

WHY I STARTED WITH C ?

C is still an influential language and most high level modern languages have been inspired by c.

  • Most operating systems are written largely in C because it provides direct control over hardware while remaining portable.
  • Small computers inside everyday devices are often programmed in C.
  • Programs that translate programming languages are often written in C or C++. c is faster than most of the high level languages.

**

HELLO WORLD IN C

**
`#include
int main()
{
printf("Hello, World!");
return 0;
}
Line 1: #include

include

What is #include?

include is a preprocessor directive.

A preprocessor is a program that runs before the actual compiler. It processes special instructions that begin with #.

Think of it as a helper that prepares your code before compilation.

What does include mean?

The word include literally means "bring something into the program."

Here, we're asking the preprocessor:

"Please include the contents of the stdio.h header file before compiling my program."

*What is stdio.h?
*

stdio stands for:

Standard Input Output

The .h means it is a header file.

This header file contains declarations for many input/output functions such as:

printf()
scanf()
getchar()
putchar()

Without this header file, the compiler won't know about these functions.

Why are angle brackets (< >) used?

include

The angle brackets tell the compiler:

"Look for this header file in the system's standard library."

If you create your own header file, you usually write:

include "myfile.h"

The double quotes tell the compiler to search the current project folder first.

What happens internally?

Suppose stdio.h contains thousands of lines of declarations.

The preprocessor copies those declarations into your source file before compilation.

Conceptually:

Before preprocessing:

`

#include <stdio.h>

int main()
{
    printf("Hello");
}
Enter fullscreen mode Exit fullscreen mode

`

After preprocessing (simplified):

c
/
* Thousands of declarations from stdio.h */

int printf(const char *, ...);

...

int main()
{
printf("Hello");
}

*KEYWORDS *

  • This are the reserve words of every language which have some specific meaning and user can not use them for any other purpose.
  • Example: int,char,float,char,switch etc.
  • There are 32 keywords in C.
  • Also C is a case sensitive lanhuahe so if and IF are not same they are different , if is a keyword while IF is not a keyword. Why should we know the key words of any programming language ? That just because while naming variables we should avoid key words else it will create some error.

**

VARIABLES AND CONSTANT

**
Variable is a type of container which is used to hold a particular type of value and this type is defined by its data type.
For example : int x;
x is a variable of integer type so it can hold only one integer value at a time
whenever a variable is defined , memory is alocated for it

CONSTANTS are the value assigned to the variable
For example: int x,y;
x=5; // 5 is assigned to x so 5 is a constant.

_Final Thoughts
_
_Strong fundamentals are the foundation of every great programmer. The time you invest in understanding the basics today will make advanced concepts much easier tomorrow.

Thank you for reading. See you in the next article as we continue exploring programming in c for absolute begineers._
_

_"Every expert programmer once wrote their first Hello, World! program."
_

Top comments (0)