Character set in C

Before starting this tutorial I would like to write and explain a small C program. Where program name is gt_first_prog.c

0    #include<stdio.h>
1    int main()
2    {
3              /* Printing welcome to gyantoday.com in my first program */
4             printf(“Welcome to gyantoday.com.\n”);
5              return 0;
6    }

step 1 -> When we do conpile above code, a executable file generate by default with a name a.out.
$  gcc  gt_first_prog.c

step 2 -> Run the executable file
$  ./a.out

Output (o/p) of this program is :-
$  Welcome to gyantoday.com.

Explanation :-
Line 0 ->  This is standard C library header file of C program which contains definition of standard  input/output functions.

Line 1 ->  This is primary (main) function of any C program. Every C program has a main function that must be named main. This is the starting point of any C program.  Also starting point for program execution.

Line  2&6 -> Every C function start with open curly braces'{‘ and end with close curly braces ‘}’ .

Line   3 ->   This is comment line which is not executable by compiler, This is just for reference that what programmer want to do. This is optional line but, it is good habit to use comment inside program so reviewer or  third person can undersatnd  about your program.

Line   4 ->  This is executable lines inside function. printf() is a o/p function used to print on standard output device. We will stdudy about i/p and o/p in details in chapter 1.7

Line   5 ->   Every program returns something to its calling function, return statement indicates the end of program. By default main returns integer type. The return value of main is returned to the operating system. It is optional line but, it is good programming practice to use return statement. As we proceed C tutorial topics one by one, we will learn use of return statement.

We can see in above C program. Where every word of program  is a set of character.

The character set in C language can be grouped into the following  categories. These character sets are used to construct building blocks of C program.

    • Lettres
  • Both  Upper (A to Z) and Lower(a to z) case alphabets:

 

    • Digits
  • 0 to 9

 

    • Special  charactors
. Period or Dot
* Asterik
; Semi colon
! Exclanation mark
| Vertical bar
/ Slash
\ Back slash
~ Tilde
& Ampersand
^ Cavet
< Opening angle
> Closing angle
( Left paranthesis
) Right paranthesis
[ Left bracket
] Right bracket
{ Left brace
} Right brace
# Number sign
_ Under score

 

  • White spaces
    • Blank page
    • Horizontal tab
    • Carriage return
    • New line
    • Form feed

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.