Ads 468x60px

Labels

Thursday, 6 September 2012

Understanding C program execution

Animation of program execution
This animation shows the execution of a simple C program. By the end of this article you will understand how it works!
The C programming language is a popular and widely used programming language for creating computer programs. Programmers around the world embrace C because it gives maximum control and efficiency to the programmer.
If you are a programmer, or if you are interested in becoming a programmer, there are a couple of benefits you gain from learning C:
  • You will be able to read and write code for a large number of platforms -- everything from microcontrollers to the most advanced scientific systems can be written in C, and many modern operating systems are written in C.

The-C-programming-language-Ritchie-Kernighan

Dennis Ritchie



Object Oriented Programming With C++ By Balagurusamy

 E. Balagurusamy


Program using printf() and scanf()


printf(): It displays output on the screen.
scanf(): It accepts input from user.

#include <stdio.h>
int main()

Precedence & Associativity of operators


Operators in C


There are three types of operators. A unary expression consists of either a unary operator prepended to an operand, or the sizeof keyword followed by an expression. The expression can be either the name of a variable or a cast expression. If the expression is a cast expression, it must be enclosed in parentheses. A binary expression consists of two operands joined by a binary operator. A ternary expression consists of three operands joined by the conditional-expression operator.

C includes the following unary operators:

Input and Output functions in C


printf

This offers more structured output than the putchar. Its arguments are, in order; a control string, which controls what get printed, followed by a list of values to be substituted for entries in the control string.

The prototype for the printf() is:

First C Program


Open command prompt
C:\TC\BIN > TC.EXE
Select New from the File menu.
Type the program in the editor.

Rules that are applicable to all C programs



                                                                                                                
   (a)  Each instruction in a C program is written as a separate statement. Therefore a complete C program
 would comprise of a series of statements.
     (b)  The statements in a program must appear in the same order in which we wish them to be
            executed; unless of course the logic of the problem demands a deliberate ‘jump’ or transfer of
            control to a statement, which is out of sequence.
     (c)  Blank spaces may be inserted between two words to improve the readability of the statement. 
           However, no blank spaces are allowed within a variable, constant or keyword
     (d)  All statements are entered in small case letters.
     (e)  C has no specific rules for the position at which a statement is to be written. That’s why it is 
          often called a free-form language.
     (f)  Every C statement must end with a ;. Thus ; acts as a statement terminator. 

Keywords,Variables and Constants in C

"Keywords" are words that have special meaning to the C compiler.Keywords are also called Reserved words.
Following are the keywords of C language

                                                          32 keyword's in C language

Variables

Variable is a meaningful name of data storage location in computer memory. When using a variable you refer to memory address of computer.

Data Types in C


  1. C has a concept of 'data types' which are used to define a variable before its use.
    C language provides various data types for holding different kinds of values.


                                                              Data Types in C



                                   















                                   Range of different datatypes in C 

Why Flow Chart ?

A flow chart is a graphical or symbolic representation of a process. 

What is C


Why ?
To develop device drivers at lower level,
Most popular in Virtual reality Systems, Embedded Systems,
Widely used in UNIX operating system development.
Who ?
It was designed and written by a man named Dennis Ritchie 
Where and When?