Unit 1- Overview of C

In this first post, i'll only give you the main & important things about the particular post. Sorry, but I'm not going to add shit as in our university book has. 

C is a computer programming language originally developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories to implement the Unix operating system.

C is named as "C"  because many of its feature were derived from an earlier language called "B".

C is known as middle level language because it has power of both low & high level language.

With C we can make machine independent programs because of its low-level capabilities.

C is also known as structured programming language.

Function parameters are always passed by value.

Pass by reference is achieved in C by explicitly passing pointer values.

C program source text is free form format.

Semicolon (;) is used as a statement terminator.

Characteristic of C:-


1- Non-nestable function definition.

2- Variables may be hidden in nested blocks.

3- Characters can be used as integers.

4- Low-level access to computer memory by converting machine addresses to typed pointers.

5- Relatively small set of reserved keywords, originally 32, now 37 in c99.

6-Equal sign is used for assignment (copying).

7- Two consecutive equal sign are to test for equality (comparison).

8- C has large number of compound operators such as ++, += etc.

Absent features in C:-


1- There is no assignment of arrays or strings.

2- No automatic garbage collection.

3- No operation on whole arrays.

K&R C


In 1978, Brian Kernighan and Dennis Ritchie published the first edition of  The C Programming Language. This book is known as "K&R". The second edition of the book covers the later ANSI C standard.

In 1983, the American National Standards Institute (ANSI) formed a committee, X3J11, to establish a standard specification of C. In 1989, the standard was ratified as ANSI X3.159-1989 "Programming Language C." This version of the language is often referred to as ANSI C, Standard C, or sometimes C89.

In 1990, the ANSI C standard was adopted by the International Organization of Standardization as ISO/IEC 9899:1990, which is sometimes called C90. Therefore the term C89 and C90 refer to the same programming language.

C89 is supported by current C compilers, and most C code being written nowadays is based on it.

The international C standard is maintained by the working group ISO/IEC  JTC1/SC22/WG14.

Syntax:-


In C, Comments may appear either between the delimiters /* and */ or following // until the end of the line.

Each source file contains declaration and function definitions. Function definition in turn contain declaration and statements. Declaration either define new types using keywords such as struct, union and enum, or assign types to and perhaps reserve storage for new variable, usually by writing the type followed by the variable name.

Keywords such as char and int specify built-in data types.

Sections of code are enclosed in braces {} sometimes called "curly braces" to limit the scope of declarations and to act as a single statement for control structures.

To modify the normal sequential execution of the statements, C provides several control-flow statements identified by the reserved keywords.

Structured programming is supported by if-else conditional execution and by do-while, while and for iterative execution (looping).

The for statement has separate initialization, testing and reinitialization expressions, any or all of which can be omitted.

Break and continue can be used to leave the innermost enclosing loop statement or skip to its reinitialization.

There is also non-structured goto statement which branches directly to the designated label within the function.

Switch selects a case to be executed based on the value of an integer expression.      

Expressions can use variety of built-in operators and may contains function calls.


Operators:-


C supports rich set of operators, which are symbols used within an expression to specify the manipulations to be performed while evaluating that expressions.

C has several operators:-



Operation                                                                Operators

Arithmetic                                                                 (+,  -,  *, /, % )

Equality Testing                                                         (==, != )

Order Relations                                                         (<,  <=,  >, >= )

Boolean Logic                                                           (!, &&, || )

Bitwise Logic                                                           (~, &, |, ^ )

Bitwise Shifts                                                          (<<, >>)

Assignment                                                             (=, +=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>=)

Increment and Decrement                                        (++, --)                                     

Reference and Dereference                                      (&, *, [] )

Conditional Evaluation                                             (? : )

Member Selection                                                   ( . , ->)

Type Conversion                                                     ( () )

Object Size                                                             (sizeof)

Function Argument Collection                                  ( () )

Sequencing                                                              ( , )

Subexpression Grouping                                          ( () )
                                                                                                                                                                                                                                                 
The main function serves a special purpose in C programs. The run-time environment calls the main function to begin program execution.

The \n is an escape sequence that C translates to a  newline character, which on output signifies the end of the current line.

Exercise:

Answer the following questions:-

1- Why C language named as C?

2- In which year C was developed and by whom? 

3- Why C is also called as middle level language?

4- We can't make machine independent program with C. Is it true? If not, then why?

5- What do you mean by "function parameters are always passed by value"?

6- What is pass by value and pass by reference?

7- How many keywords are available in C?

8- Explain the role of = sign in C?

9- What is the main difference between = and == sign?

10- Who maintain the international C standard?

11- What is the difference between /* */ and // ?

12- What is data types? Explain different types of data type?

13- What is the role of control flow statement?




Hope you liked it. If you have any problem ask in  comments. Thanks for reading.
Next PostNewer Post Previous PostOlder Post Home