Search

Sunday, May 13, 2018

3. Component of a C program

To develop a C program we need few fundamental components, they are:
  1. Keywords
  2. Operators
  3. Separators
  4. Data-Types
  5. Pre-Defined Functions

1. Keywords:

  • Keywords are predefined, reserved words used in programming that have special meanings to the compiler. Keywords are part of the syntax and they cannot be used as an identifier.
  • In C programming language total number of keywords are 32.
  • These keywords are:
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. Operators:

  • An operator in a programming language is a symbol that tells the compiler or interpreter to perform specific mathematical, relational or logical operation and produce final result.
  • In C programming language we have 44 operators.
  • These operators are:
Operator
Type
()     []     .     ->

++    --    +    -    !    ~    (type)    *    &    sizeof
unary Operator
*     /     %    +    -
arithmetic Operator
<<    >>
shift Operator
<    <=    >   >=    ==   !=
relational Operator
&
bitwise AND
^
bitwise Ex-OR
|
bitwise OR
&&
logical AND
||
logical OR
?:
ternary Operator
=   +=   -=   *=   /=   %=   &=   ^=   |=   <<=  >>=
assignment Operator
,
comma

3. Separators:

  • By using separators we can separate  an individual unit like keyword from keyword, keyword from identifier, identifier from other identifier etc.
  • In C programming every expression is separated using white space character/s, statements are separated from other using semicolon ;.
  • We can use any number of white space characters to separate two expressions. However we must use at least single white space character to separate one programming element from other. 
  • We can also use number of semicolon to separate one statement from other.
  • Example:  ,   ;   :  "   '  { }  [ ]  ( )  etc.

4. Data Types:

  • The data type of a variable is an attribute that tells what kind of data that variable can have.
  • A data type is a data storage format that can contain a specific type or range of values.
  • When computer programs store data in variables, each variable must be assigned a specific data type.
  • Data Types are classified into two parts.
    • Alpha Numeric Data.
    • Numeric Data.

Alpha-Numeric Data:

  • By using this data type we can represent alphabets, numeric values.
  • Under alpha-numeric we having only one type of data type i,e., char.
  • In C programming language we having only 256 characters.
  • These 256 characters are combination of 52 alphabets, 44 operators, 14 separators, 0-9 numeric values and some special kind of symbols which is not possible to represent by keywords.
  • When we are working with character, character representation must be within single quotes only.
  • Example: 'A' ,  'd'  . '+'   'S'  ,  '@'  '1' etc.

Numeric Data:

  • By numeric data type we can represent value type data.
  • Numeric data types are classified into two types:  
    • Integers
    • Floats.
Integers:
  • Integer will represent the value without any fractional part.
  • Example:  20, 30, 1, 23, -43, 16, 31, etc. 
Float:
  • Float will represent the numeric values with fractional part.
  • Example: 12.3, -14.43, 7.8, -454.543, etc.
**Note: int, float and char are called basic data types or basic data elements. Because any data is combination of these three types of constants.

5. Pre-Defined Functions:

  • The implementation part of the function which is available along with the compiler, those are called pre-defined functions.
  • As a programmer when we require to perform any specific task we require to call a function.
  • Example: printf(), scanf(), clrscr(), getch(), gettime()  etc

No comments:

Post a Comment

4. Operator And Operator Behavior

It is a special kind of symbol which performs a particular task. In C programming language total number of operators are 44 and dependin...