Pages

January 20, 2013

Starting with C-language


steps in learning C language as compare to english language


Communicating with a computer involves speaking the language the computer understands, which immediately rules out English as the language of communication with computer. However there is a close analogy between learning English language and learning C language. The classical method of learning English is to first learn the alphabets used in the language, then learn to combine these alphabets to form words, which in turn are combined to form sentences and sentences are combined to form paragraphs. Learning C is similar and easier. Instead of straight-away learning how to write programs, we must first know what alphabets, numbers and special symbols are used in C, then how using them constants, variables and keywords are constructed, and finally how are these combined to form an instruction. A group of instructions would be combined later on to form a program.


constant in C programming language


CONSTANTS

A constant is an entity that doesn’t change before and after the execution of the program.



VARIABLE

It is a name given to the location in memory where constants are stored. The value of variable may change during the execution of the program.


DATA TYPE

It determines the type and size of values that can be stored in particular variable.


  • INTEGRAL CONSTANT

In this type we can store whole numbers and size of the data types varies from 1 byte  4 bytes.
Signed integer use 1 bit for storing the sign of the number and the remaining bits to represent the magnitude of the number.
( 1byte = 8 bits)


integer constants in C and C++ (OOPs) language


  • FLOATING POINT

These are used to store fractional and exponential numbers. The size of this varies from 4 bytes to 10 bytes. The different floating types in ‘C’ are:


floating or real type variables in C and C++ (OOPs) programming


  • CHARACTER DATA

 A single character can be represented character data type. There is only one character data type ‘char’. Size is 1 byte.

IDENTIFIERS

basic identifiers explanation


It is names given to program elements and identifiers represents unique sequence of characters. There are certain rules for naming :


identifiers composition in C and C++ language
1. Identifiers can be composed out of A to Z
                                                                  a to z
                                                                  0 to 9
                       Special symbol ‘_’ (underscore)


2. The name of the identifier begins with an alphabet. Example: a1, a_1 etc.

3. The length of an identifier cannot exceed 31 characters.

4. These are ‘k’ sensitive. Example: marKs and marks are different.

5. Certain words known as keywords* can’t used as identifiers.

*keywords : These are reserved words that have special meanings for the C- compiler. Keywords can’t use as identifiers. There are 32 words in ‘C’ some of them are: int, float, long, double, for etc.  

keywords that can't be used as identifiers in the C programming

No comments:

Post a Comment