C Syntax and Basics – POFTUT

C Syntax and Basics

[rps-include post=6557]

We have successfully compiled our application. But while compiling we have no detailed information about the program. In this chapter we will look basics of C programming language.


The smallest part of a C program is tokens. Compilers start by reading source code and parsing tokens. If there is an unexpected token compile process will stop and give error. From developer point of view tokens are not so important. Below there is an example about tokens.

  • printf
  • (
  • “Hi”
  • )
  • ;


In C semicolons are used as statement terminator. Each statements end with a semicolon. One of the most error causes is missing semicolon. Following code part will generate and semicolon error.

           printf("Hello, Poftut! \n"); 
           return 0 

As we see in the screenshot we will get an error like expected ';' ... if we missed the semicolon.


Statement is smallest part of the C which is meaningful from point of developer.  Statements are delimited with semicolons like below.

printf("Hello, Poftut! \n");

This statements prints some text to the standard output

return 0;

This statement return 0 from a function

int age;

This statement will create a variable named age.

If semicolon is not used for a statement it will give error not will not compiled.


Comments are very important facility of C programming language. Writing program-rams is not just writing code . To write understandable code there should be documentation for yourself and others. These documentation can be done in the source code without effecting the application process. Comments are the way to documents our source code. Comments are not compiled or executed. Below example we can see there is two type of comment.

  • Single line comments wraps only single line and specified with //
  • Multi line comments wraps multiple lines and starts with /* , ends with */
 #include stdio.h 
int main(){ 
//This is a comment for single line 
This is an other comment 
for multiple lines 
printf("Hi poftut.com"); //This is a comment too 
return 0 


Identifiers are used to set names for variable, functions and user defined items. Identifiers can use letters A to Z, a to z, underscore _ and numbers. But numbers cannot be used as first character in the identifier Here are some acceptable identifiers.

a    a10    var_x    AAA    myfunction    _temp    Temp

Here are some unaccepted identifiers

10a    @var    a$    %myfunction

Case Sensitive

C is case sensitive language. Which means age is not same with Age . They specify different things. Following example will produce error.

#include stdio.h 
int main(){ 
int age=30; 
return 0 
Case Sensitive
Case Sensitive

AGE variable is like undefined.


Keywords are reserved words all ready used by C language. For example char is used to define character variables and can not used as variable, function and other user defined items name. Following usage is forbidden by C programming language.

int char;

We can not use char as variable name.

C identifier error

Here are keyword used by C.

LEARN MORE  Local Group Management For Windows From Command Line
auto else long switch
break enum register typedef
case extern return union
char float short unsigned
const for signed void
continue goto sizeof volatile
default if static while
do int struct _Packed

[rps-include post=6557]

Leave a Comment