C Basic Syntax

Comments in C programming language

Comments are used to explain C code. Comments are also used to prevent the execution of code while testing. Comment lines are ignored by the compiler. In C programming language there are two types of comment,

  • Single line comment
  • Multi-line comment

Single line comment

The single-line comment is used to comment a single line of code in a C program. Single line comment starts with two forward slashes(//). This type of comment is used at the end of a code line and we cannot use it within a code line.

#include <stdio.h>

int main() //This is the main function
{
    printf("Hello Neural Beast"); //This is a printing statement
    return 0; //This is a return statement
}

Multi-line comment

Multi-line comments are used to comment more than one line in C program. Multi-line comment starts with /* and ends with */ . Everything between these character combinations are ignored by the compiler.

#include <stdio.h>

int main()
{
    printf("Hello Neural Beast");
    /*
    This is an Example
    for multi-line
    comment
    */
    return 0;
}

Tokens in C programing language

A Token is the smallest unit or basic building block of a C program. A program contains various tokens such as keyword, string literal, identifier, or a symbol. The compiler breaks the C program into smaller units called tokens and sends it to various stages of the compiler to process.

{
printf("Hello Neural Beast");
}

The individual tokens are,

{
printf
(
"Hello Neural Beast"
);
}

Identifiers in C programming language

Identifiers represent a name used to identify a function, array, variable, unions, etc in C programming language. An identifier can contain letters such as uppercase and lowercase, numbers from 0-9, and underscore. An identifier should not contain symbols such as @, #, $, and %. The First character of an identifier should be a alphabet or underscore.

Note: In C programming language Identifiers are case-sensitive, Neural and neural are two different identifiers.

#include<stdio.h>

int main()
{
    int Num_1, Num_2, sum = 0;
    Num_1 = 10;
    Num_2 = 20;
    sum = Num_1 + Num_2;
    printf("Sum of the value is: %d", sum);
    return 0;
}

Keywords in C programming language

Keywords have special meaning to the language compiler. Keywords are reserved words and keywords cannot be used as a variable name or constants or other identifier names. In C programming language there are 32 reserved keywords. The keywords should be written in lower case. C keywords cannot be used as a variable name because keywords are assigned with fixed meaning.

autodoublelongswitch
breakenumregistertypedef
caseexternreturnunion
charfloatshortunsigned
constforsignedvoid
continuegotosizeofvolatile
defaultifstaticwhile
dointstructelse

White-space in C programming language

C programming language allows white-space, i.e, Tabs, blank lines, spaces, etc. In C white-space are ignored by the compiler.

#include <stdio.h>

int
main()
{

    printf

    ("Hello Neural Beast");
    return 0;
}

More Reading

Post navigation

Leave a Comment

Leave a Reply

Your email address will not be published. Required fields are marked *