C-Programming

             
C-Programming...

C is a programming language designed by ‘DENNIES RITCHIE’ at AT& T Bell Labs in USA in 1972. The C programming Language is basically mother of all the languages. It is a powerful language. It is middle level language because it combines of best features of high level language with the control and flexibility of low level language and its also a function oriented. It is a powerful system programing language because of the access it provides to the addresses where variables are stored distinguishing C from programming like FORTRAN and COBOL. 

CHARACTER SET--

There are so many character set that used in a single program. Character set is a set of valid characters that a language can recognize. A character setr is the combination of letters, digits or any other sign. The C has the following character set:--

(Letter or Alphabet)
Lower case--a__to__z.
Upper Case--A__to__Z.
(Digits)  
0,1,2,3,4,5,6,7,8,9

SYMBOLS
,   (Comma)                            ~   (Tiled)                                 <   (Less than)
.   (Period)                              $   (Doller)                               >   (Greater Than)
;   (Semi colon)                      #    (Hash)                                =   (Equal to)
:   (Colon)        %   (Percentage)                          (Vertical Bar)
?  (Question Mark)        &   (Ampersand)
‘   (Apostrophe)        [ ]   (Index Brackets)
“   (Quotation Mark)        { }  (Braces)
_   (Underscore)         +    (Plus)
( ) (Paranthesis)          -    (Minus)
/    (Slash)          *   (Asterisk)
\    (Blank Space)          ^    (Caret)

Token 

A token is a smallest individual unit is a program.. C has Six following Tokens types:-
  1. Keywords
  2. Identifiers 
  3. Operators 
  4. Constant 
  5. Strings Constant
  6. Special Symbol

Keywords:-

These are the reserve words whose meaning cannot be changed by the programmer. These words can’t be used as a variable name, constant of other user-define program elements.
Ex- int, float, char, void, main, for, if, else, else-if etc.

Identifiers:-

The name of any variables, function, array, class etc. that are created by programmer is called identifiers. 
Ex- int a, arr[10];
       float b;

Constant:--

The fixed value that can not we changed by the programmer during the execution of program is called constant.
Ex- int a=10;
      Float b=5.5;

String Constant:--

They are sequence of characters, strings, digits  enclosed in double quotes.
for ex: "hello","112233","$%#hiii$%#" etc..

Operators:--

Operators are token that triggers or run automatically some action when applied to variables and others objects in an expressions. For ex: +, - , = , / , * etc.

Special Symbols:--

They are known as seperators and they are square brackets[ ], parentheses( ),braces{} etc. They [ ] used in array and known as SUBSCRIPT OPERATOR and symbol () is known as function operator.

Counting of Tokens:--

This helps us to know how  many types of Tokns are present in the single  statement.

1.int a,b,c;
  • int is a keyword--1
  • a,b and c are variables--3
  • ; is a delimiter--1
  • comma(,) is a separator--2
total no. of tokens are-1+3+1+2=7

2.printf("%d%d",10,20);
  • printf is a function--1
  • 10,20 is a interger constant--2
  • ; is a delimiter--1
  • "%d%d" is a string constant--1
  • comma(,) is a separator--2
  • comma(,) is a operator--2  (because this comes inside the printf function so it work both as a operator and as a separator  )
total no. of tokens are 1+2+1+1+2+2=9

3.d='A'+10/2-34;
  • d is a variable--1
  • 'A' is a string constant--1
  • 10,2,34 are integer constant--3
  • =,+,-,/ are operators--4
  • ; is a delimiter--1
total no of tokens are-1+1+3+4+1=10

Write a program to print "Hello C":- 

#include<studio.h>

main()
{
a="Hello C"
        printf(a) 
}

output:----

Hello C

Compilation and Execution

  • Compilation is a process in which your input  source program is checked for any syntactical or syntax errors like missing semicolons(:), comma(,), operators, wrong expression, wrong use of operators etc.
  • If everything is ok then compiler generates an .obj file(contains object code),and one more file with the extension .bak (contain backup code for object) 
  • The compiler generate file .obj is passed to the linker who does the job of linking the necessary file to your program and generates an .exe version of your program which you can run by simply typing typing the file name in command prompt.
  • When you press ctrl+F9, 3 files are generated, .obj, .bak and .exe



Comments