Introduction to C
Topics Covered :
- History of C
- Characteristics / Features
- Structure of a C Program
- Desirable Program Characteristics
- C Character Set
- Identifiers & Keyword
- Constants
- Expression
- Statements
- Symbolic Constants
Well i hope this helped a few new commers to the programming field, I am a little bored and tired now .. but will finish the next topic of Operators & Expressions in C , in the next tutorial. Suggestions and Critisizm are welcomeHistory of C
- This language was developed by Dennis Ritchie in 1970 at t he Bell Lab.
- It was official released only in 1978.
- 1980s it evolved as a most effective language because of its desirable features.
- It was instantly adapted even for developing commercial applications
- Many Software products which were written in other languages we rewritten in C for its efficiency and portability.
- With the advent of C many C compilers and interpreters were written and released into the market
- They differed from the original C language this lead to the lack of portability that the language promised to provide
Characteristics / Features
- AT this point ANSI developed certain standardized norms for the C language and today all C compilers adhere to this ANSI Standard.
- Ability to write very concise source codes in spite of having a large number of operators.
- It has a small instruction set
- It has library functions that enhance the basic instruction.
- The features and capabilities can be easily extended b the users as it encourages users to write additional library functions
- C Compliers are compact and generate smaller and highly efficient object code compared to other high level languages.
- C Programs are highly portable as its library set avoids all to computer dependent features.
- C Compliers are compact and generate smaller and highly efficient object code compared to other high level languages.
Structure of a C Program
- C Programs are highly portable as its library set avoids all to computer dependent features.
CODE/* Simple Program to Add 2 Values*/ /* Title*/[/color]
[color="#996633"]# Include<stdio.h> /*Library File Access*/
main() /* Function Heading*/
{ /* Start of the Function*/
int n1,n2,sum; /* Variable Declaration*/
printf(“Enter First Value : “); /* Output Statement */
scanf(“%d “,&n1); /* Input Statement */
printf(“Enter Second Value : “); /* Output Statement */
scanf(“%d “,&n2); /* Input Statement */
sum=n1+n2; /* Assignment Statement*/
printf(“Sum is : %d “,sum); /* Output Statement */
} /* End of function Main*/
Desirable Program CharacteristicsC Character Set
- Integrity
- Clarity
- Simplicity
- Efficiency
- Modularity
- Generality
These are used as building blocks to form basic program elements
- Uppercase A - Z
- Lowercase a - z
- Digits 0 – 9
- Special characters
Identifiers & Keyword
Names given to basic program elements such as variables, Functions etc. Certain norms they have to follow:Constants
- Name can be of alphanumeric type
- But should start with a alphabet
- It is case sensitive
- Keywords are reserved words that have a predefined function in C
- Keywords can be used only for the purpose they are intended for
- Keywords Cannot be used as program defined identifiers
They contain a specific value.
Four types :
Integer & Floating Point Constants
They are normally reffered to as numeric constants
Follow certain norms:Integer Constants
- Commas and blanks cannot be included within the constant
- Can be preceded with a – sign if required
- Value should be within the specified range .
These are nothing but integer valued numbers.
Can be written in 3 number systems :Contains digits between the set 0 to 9
- Decimal Integer Constant ( Base 10)
If consists of more than one digit should start with a value other than zero.Contains digits between 0 to 7
- Octal Integer Constant ( Base 8)
First digit must be a zeroBegins with a either 0x or 0X followed by digits
- Hexa Integer Constant (Base 16)
Set could contain 0 to 9 and a – f (Lower or Uppercase)
Floating Point Constants
- This is a base 10 number having a decimal value or a exponent.
Eg : 10.8X 10 -3 : 10.8E-3 or 10.8e-3
- In case of representation of a exponent is similar to the scientific notation except that 10 is replaced by E or e
Character Constants
- Single character enclosed within Single apostrophes
- All character constants have integer values that determine them in the character set .
Combination of special characters that are used for special purpose .
- Character set standardized by the ASCII here each character is numerically encoded with its own unoaque 7 bit coding
Always started off with a \ .
Eg \n, \t etc.
String ConstantExpression
- Consecutive sequence of characters within double quotations.
- Uses \0 ( Null) string terminator at the end of the string.
Eg. C=a+b;
- Represents a single data item which could be a number or character .
- It could be single entity as a variable function or constant or a combination of entities connected by a operator.
Statement
This Causes the computer to perform a action
Types:
- Expression Statement
- Compound Statement
- Control Statements.
Symbolic Constant
- Name that substitutes with a sequence of characters.
- These sequence of characters could represent a numeric , character or a string constant.
- They have to be defined at the beginning of the program
- Done by using the keyword : # define pi 3.141
Regards
Dhanesh.


