About this Series

Welcome everybody, you must be interested in learning about the programming. Guess what, you’re at the correct place. In this series we will learn about how to in and out of C language from very basics of programming to a pretty intermediate level. This post mainly contains the keywords, comments and variables in C.

C logo

If you wanted to take a look at history of C then checkout my previous post in this series.

Previous post

Setup

Text Editor

I have already asked you guys to set up a visual code editor. I recommend Visual Studio Code

Compiler

Another thing which is required is Compiler, I have created another post for installing a compiler.

Installing C/C++ (GCC) compiler On Windows

Basics of C

To successfully execute a program in C, first we need to save it in a file, then we have to compile it (in our case using GCC). Next step is we need to run this compiled program. If no name given while compiling then, it will be saved in same directory with name “a.exe”(in windows).

Ritual

First, let’s perform a well known ritual in programming field, which is writing/printing “Hello World!” code in beginning of learning in any programming language.

#include <stdio.h>  
  
int main(int argc, char const \*argv\[\])  
{  
 printf("Hello World!\n");  
 return 0;  
}

Save this program as the hello.c, then compile it using

gcc hello.c

Next step is execute this program.

a.exe

You can see all the steps from GIF.

hello world

Semicolons

A semicolon terminates the statement. You can see Ritual program as example.

Comments in C

Almost every programming contains comments. C has two types of them.

  1. // (single line comments)
  2. /* …….. */ (multiline comments)

first

// this is single line comment in c 

Second,

/* this is multiline comment in  
c language  */

Keywords

Each programming language contains some reserved keywords for some specific purpose. C has a lot of them, let’s look at them.

  1. auto
  2. else
  3. long
  4. switch
  5. break
  6. enum
  7. register
  8. typedef
  9. case
  10. extern
  11. return
  12. union
  13. char
  14. float
  15. short
  16. unsigned
  17. const
  18. for
  19. signed
  20. void
  21. continue
  22. goto
  23. sizeof
  24. volatile
  25. default
  26. if
  27. static
  28. while
  29. do
  30. int
  31. struct
  32. _Packed
  33. double

Identifiers in C

A C identifier is a name used to identify variables, functions or any other user-defined item. A variable name cannot be started from a number. An identifier starts from A to Z, a, z, or an underscore ‘_’ followed by zero or more letters, underscores, and digits (0 to 9).

C language is case-sensitive programming and does not allow the special character like the @,$,%,# etc.
Example names.

vari, _test, test, test123_  => all these keywords are astill supported in few parts of india. 
23var => this implementation is wrong. 

WhiteSpace in C

If a line is blank line, while compiling compiler completely ignores it.

int money;

There must be at least one whitespace character (usually space) between int and variable name (money) for compiler distinctly find them and storing them into memory for later resolution.

money = original + interest; // this gets the total money

While in this example, no whitespace characters are necessary between money and =, or between = and original, although you are free to include some if you wish to increase readability.

That’s it for this tutorial.

Thanks for being here. If you have any issue please drop them in comments.

Next Part (part 3)