Elements of C

                                Every language has some basic elements and grammatical rules. These basic elements are character set, variables, datatypes, constants, keywords, variable declaration, expressions, statements etc,. all of these are used to construct a c program.

2.1 Character set:

Upper and lower case
                        A,B,C,D,……..Z
                        A,b,c,d,………z
Digits
                        1,2,3,4,….
Graphic Characters


White space characters
                        Space character, neline character, horizontal tab, vertical tab, and form feed.
Other characters
                        Alert, backspace, carriage return, and null character.

2.2 Escape sequence/ Execution characters:

                       C supports combination of backslash ( \ ) and some characters from the C character for representing these characters in our C programs. These characters are known as escape sequences.


2.3 Delimiters

These are used for syntactic purpose in C

               :           colon                     used for label
               ;           semicolon             end of statement
               ()          parentheses          used in expression
               []          square brackets    used for arrays
               {}          curley braces       used for block of statements
                #          hash                     preprocessor directive
                ,           comma                 variable delimiter

2.4 Keywords:

                       Keywords are the vocabulary of C. Because they are special to C, you can't use them as identifiers, for example, or as variable names. Many of these keywords specify various types, such as int. Others, such as if, are used to control the order in which program statements are executed. These are always written in lowercase. There are only 32 keywords available

auto       break    case      char        const       continue   default           do         double         else
enum     extern    float       for          goto         if             int                  long      register        return    
short     signed    sizeof     static       struct       switch      typedef          union    unsigned      void      volatile        while

2.5 Identifiers :

                        All the words that we will use in our c program will be either keywords or identifiers. Keywords are predefined and can’t be changed by the user, while identifiers are user defined words and are used to give names to entities like variables, arrays, functions, structures etc., Rules for naming identifiers are

Rule 1: the name should consist of UPPERCASE, lowercase, digits and underscore(_).
Rule 2: First character should be alphabet or underscore.
Rule 3: The name should not be a keyword.
Rule 4: C is a case sensitive, the lowercase and uppercase letters are different.
Rule 5: Some implementations of C recognize only the first eight characters, though most implementations recognize 31 characters.

Examples of valid Identifiers are :

Temp                a          _initial               data_type         Marks               Percent

Invalid identifiers are:

5abd                 int         rec#      avg.no              high num(space not allowed)

Keep in mind all these rules before using identifier.

Environment for C

The steps involved in developing a C program are –
A. Program Creation
B. Program compilation
C. Program Execution

UNIX/LINUX Environment:
                        Requirements for UNIX are Terminal(ctrl+alt+t), Text editor like vim, gedit, emacs, …. And Compiler. Examples are written by using Vim editor and compilation by GCC Compiler. 
To install this, type the command in terminal 
                                                “apt-get install vim “(for debian pkg) and 
                                                 GCC is default one of the GNU tools.
a.    program creation:
            $vim filename.c
press insert and type the program in this file after completing press ESC and :wq it save and exits from terminal.
b.    Program compilation:
            $ gcc filename.c
After successful compilation you get binary file: a.out in that current directory.
You want to give user defined name to binary then follow this
$ gcc filename.c -o user_name
After successful compilation you get binary file: user_name in that current directory.
                               c. Program execution: 
                                           $./a.out   or 
                                           $./user_name. 
  Then Out put is displayed in the terminal. 

Compilation and Execution of C programs

There are different phases through which our program passes before being transformed into an executable form. The following figure shows these phases –

Let us take one  example program : onsettechie.c

Preprocessor:

            The source code is the code that we write using any text editor and the source code file is given an extension ‘.c’. This source code is firstly passed through the preprocessor. The preprocessor expands this code and passes it to the compiler.
                                        gcc -E onsettechie.c -o onsettechie.i

Compiler :
            The expanded code is passed to the compiler. The compiler converts this code into machine’s assembly language code.
                                       gcc -S onsettechie.i -o onsettechie.s

Assembler:
            This assembly language code is converted to object code by the system’s assembler. The name of the object file is same as that of source file. The extension in UNIX is ‘.o’.
                                       gcc -c onsettechie.s -o onsettechie.o

Linker:
            All programs written in C, use library functions. Library functions are precompiled and their object code is stored in library files with ‘.lib’ ( or ‘.a’) extension. The linker combines both the object code of library functions with the object code of our program. The output of the linker is executable file. In UNIX name is a.out or other name with -o option.
                                       gcc -E onsettechie.o -o onsettechie

Here you get little bit confusion go forward then you understand about about all these files.
onsettechie.c is source code.
onsettechie.i  is expanded code.
onsettechie.s is Assembly code.
onsettechie.o is Object code.
onsettechie    is binary executable.
you can these codes by using Vim editor.

Structure of C program

A C program is a collection of one or more functions. Every function is a collection of statements and performs some specific task. The general Structure of C program -

Comments can be placed anywhere in a program and are enclosed between the delimiters /* …. */ , Single line comments // …. , #if 0 …… #endif. (….. are statements).
example :

/*   this is Example program in generic here writing about Program theme   */

#include // this is preprocessor directive
int main() {
          printf("Welcome to Onsettechie");
#if 0
         printf("this is comments part");
#endif
return 0;
}

Preprocessor directives are processed through preprocessor before the C source code passes through Compiler. the Commonly used preprocessor directives are #include including header files, #define is used to define symbolic constants and macros.
Every C program has one or more functions. Execution of every C program starts with main() function. The statement return 0 at the end of main() means that the function is terminated Successfully.
Other functions are user Defined functions, which also have local variables and C statements. They can define Before or after main() function.

Introduction

                                   Software is a collection of programs and program is a collection of instructions given to the computer. Development is a stepwise process, before developing a software number of processes are done. The first step is to understand the user requirements. Problem analysis arises during the requirement phase of software development. Problem analysis is done for obtaining the user requirements and to determine the input and output of a program. For solving any problem, an algorithm is implemented.
                                             Process of Program Development

1. Programming Languages:
Before Learning any language, it is important to know about the various types of languages and their features. The Languages are classified into two types.
1.    Low level Languages
2.    High level Languages

     1.1.    Low level Languages:
The Languages in this category are the Machine level and Assembly level languages.
1.1.1     Machine level Language:
         Computers can understand only digital signals, which are in binary digits i.e., 0 and 1. So the instructions given to the computer can only in binary codes. The machine language consists of instructions that are in binary 0 or 1. Computers can understand only Machine level Language.
          Writing a program in machine level language is a difficult task because it is not easy for programmers to write instructions in binary code. A machine level Language program is error-prone and its maintenance is very difficult. Every computer has its own Machine Instructions, so the programs written for one computer are not valid for other computers.
1.1.2     Assembly Language
          The difficulties faced in machine level language were reduced to some extent by using a modified form of Machine level language called assembly language. A computer can understand only machine level language, assembly language program must be translated into machine language. The translator that is used for translating is called “assembler”.
In this Language data stored in Computer registers and each computer has different set of registers. The assembly Language is not portable. Since the low level Languages are related with the hardware, the execution of a low-level program is faster. 
      1.2  High level Language :
            High -level Languages are designed keeping in mind the features of portability i.e., these languages are Machine independent. While programming in a high level language, the programmer is not concerned with the low level details, and so the whole attention can be paid to the logic of the problem being solved. For translating high-level languages into machine language, compiler or interpreter is used. Every Language has its own Compiler or interpreter.
    2.    Translators :
           Translators are just a computer programs, which accept a program written in high level or low level language and produce an equivalent machine language program as output. Three types of translators used are
a.    Assembler
b.    Compiler
c.     Interpreter
                    Assembler is used for converting the code of low level language (assembly language) into Machine Language.
                    Compilers and interpreters are used to convert the code of high-level language into Machine language. The High level program is known as source program and corresponding machine language is known as object program.
                    Compiler Searches all the errors of the program and lists them. If the program is error free then it converts the code of program into machine code and then the program can be executed by separate commands. An interpreter Checks the errors of program statement by statement. After checking one statement, it converts that statement into machine code and then executes that statement. This process continues until the last statement of program or erroneous statement occurs. 

Why I learn C, After all these Years the world still Powered by C ?

In my point of view i definitely say YES, because 
                     The UNIX operating system’s development started in 1969, and its code was rewritten in C in 1972. The C language was actually created to move the UNIX kernel code from assembly to a higher level language, which would do the same tasks with fewer lines of code.
                 Oracle database development started in 1977, and its code was rewritten from assembly to C in 1983. It became one of the most popular databases in the world.
                   In 1985 Windows 1.0 was released. Although Windows source code is not publicly available, it’s been stated that its kernel is mostly written in C, with some parts in assembly. Linux kernel development started in 1991, and it is also written in C. The next year, it was released under the GNU license and was used as part of the GNU Operating System. The GNU operating system itself was started using C and Lisp programming languages, so many of its components are written in C.
                     But C programming isn’t limited to projects that started decades ago, when there weren’t as many programming languages as today. Many C projects are still started today; there are some good reasons for that.
Linux:
                    Linux is also written mostly in C, with some parts in assembly. About 97 percent of the world’s 500 most powerful supercomputers run the Linux kernel. It is also used in many personal computers.
Mobile :
                    iOSAndroid and Windows Phone kernels are also written in C. They are just mobile adaptations of existing Mac OS, Linux and Windows kernels. So smartphones you use every day are running on a C kernel.
Database:
         The world’s most popular databases, including Oracle Database, MySQL, MS SQL Server, and PostgreSQL, are coded in C (the first three of them actually both in C and C++). Databases are used in all kind of systems: financial, government, media, entertainment, telecommunications, health, education, retail, social networks, web, and the like.
Embedded Systems :
               Imagine that you wake up one day and go shopping. The alarm clock that wakes you up is likely programmed in C. You turn on your TV or radio while you eat your breakfast. Those are also embedded systems, powered by C. When you open your garage door with the remote control you are also using an embedded system that is most likely programmed in C.
                    All those devices are embedded systems. They are like small computers that have a micro-controller/microprocessor inside that is running a program, also called firmware, on embedded devices.

Why the C Programming Language Still Used?
                    There are many programming languages, today, that allow developers to be more productive than with C for different kinds of projects. There are higher level languages that provide much larger built-in libraries that simplify working with JSON, XML, UI, web pages, client requests, database connections, media manipulation, and so on.
                       But despite that, there are plenty of reasons to believe that C programming will remain active for a long time.
                       In programming languages one size does not fit all. Here are some reasons that C is unbeatable, and almost mandatory, for certain applications.
                 The C programming language doesn’t seem to have an expiration date. It’s closeness to the hardware, great portability and deterministic usage of resources makes it ideal for low level development for such things as operating system kernels and embedded software. Its versatility, efficiency and good performance makes it an excellent choice for high complexity data manipulation software, like databases or 3D animation. The fact that many programming languages today are better than C for their intended use doesn’t mean that they beat C in all areas. C is still unsurpassed when performance is the priority.

The world is running on C-powered devices. We use these devices every day whether we realize it or not. C is the past, the present, and, as far as we can see, still the future for many areas of software.