GETTING STARTED C PROGRAMMING/LECTURE-1

C programming


As u see this heading several questions arises in mind…. What is programming??? What is the need 
of it? Why it is so popular these days… etc.
Don’t worry...u will get to know about all that.
Second type of question arises… why we should learn C first when these days there are several languages available which are far better than C. Answer to this question is…. U should learn how to drive in a simple cab … before u drive a sports car in a race …J

Introduction to C


C is a programming language developed at AT & T’s Bell Laboratories of USA in 1972. It was designed and written by a man named Dennis Ritchie. In the late seventies C began to replace the more familiar languages of that time like PL/I, ALGOL, etc. No one pushed C. It wasn’t made the ‘official’ Bell Labs language. Thus, without any advertisement C’s reputation spread and its pool of users grew. Ritchie seems to have been rather surprised that so many programmers preferred C to older languages like FORTRAN or PL/I, or the newer ones like Pascal and APL. But, that's what happened.

Why C


1. I believe that nobody can learn C++ or Java directly. So one should first learn all the language elements very thoroughly using C language before migrating to C++, C# or Java.  
2. C++, C# or Java make use of a principle called Object Oriented Programming (OOP) to organize the program. but you would still need a good hold over the language elements of C and the basic programming skills. 
3. Major parts of popular operating systems like Windows, UNIX, Linux is still written in C.  This is because even today when it comes to performance (speed of execution) nothing beats C. Moreover, if one is to extend the operating system to work with new devices one needs to write device driver programs. These programs are exclusively written in C. 
 4. Many popular gaming frameworks have been built using C language. Becoz of it’s speed
5. At times one is required to very closely interact with the hardware devices. Since C provides several language elements that make this interaction feasible without compromising the performance it is the preferred choice of the programmer.

Getting started


There are different types of languages in this world and different persons use them for example in order to communicate with a usual American person u should know English. Same is the case with computer in order to communicate with computer u should know computer language. Further there are various computer languages. For example C,C++ FORTRAN etc.
 As we have discussed earlier in previous lectures there are three types of languages
1.     1.  High Level Language
2.      2. Assembly level language
3.      3.  Low level language

These days we use high level languages becoz they are easy to understand by the user
C is one of the high level language

As for using English you should know the letters used in that language
·       >>>  Letter makes words, words make sentences and sentences make paragraphs
Similarly……………………….
·       >>>  Special symbols make keywords, Keywords make statements, statements make program


Character set in C

VARIABLE: it is a container of data usually used in a program

SUB ROUTING: it is a combination of statements that can be used in a program to perform specific task

PSUDOPOD: it is a collection of little statement of algorithm using a restricted & well defined vocab.

PROGRAMMING LANGUAGES:
the first programming language is called machine language
  • in the machine language the program is dependent on machine
  • instruction set is different for all machines
  • in machine language there is no portability mechanism
    Second programming language is H.L.L       
       
         like
  • SIMON- simulation language
  • LISP- list processing , list is used for artificial intelligence, the drawback of these are the programs can't be editied
Further classifications of program
  1. Input program( Source Code)
  2. Output program( Object Code)
compiler and interpreter both are written in H.L.L and can vary from machine to machine also from one generation to another generation

IMPORTANT POINTS REGARDING C
  1. C is a H.L.L.
  2. C is used to write operating system as well as application program
  3. C is a general purpose & structural programming language
  4. C resembles English keywords
  5. C resembles PASCAL, FORTRAN.
  6. C binds the gap between machine language and H.L.L
  7.  C has additional features to use L.L.L
  8. C has some library files that contains functions & statements usually used in a program
  9. each version of C has updated library files
  10. C is a portable language
  11. c uses compiler
  12. C was developed by Denis Ritche at Bell telephone lab(AT&T)
Characteristics of C

  1. Integrity: programs are meaningful and there should be accuracy of the calculations
  2. Clarity: program should be simple
  3. Simplicity: program should be simple
  4. Efficiency: speed and memory utilization 
  5. Modularity: the  program should be in different modules
  6. Generality: program should be general
(FILES USED IN C PROGRAM)

  1. SOURCE FILE: it includes program written by  programmer, the extension of C source program is .C , a source program is also known as input program.
  2. OBJECT FILE:  after processing source file a new file or sett of new files are created by compiler, these files are called object files the extension of object is .OBJ or .O
  3. EXECUTABLE FILE:  the function of liner is to combine multiple object files & create a new executable file for the purpose of direct execution the extension is .EXE 
  4. TOKEN: tokens are the smallest unit of program these are 
  • keywords: keywords are standard words used for their intended purpose
  • identifiers: identifiers are the name of element such as name of variable, function, array used in a program. 
           properties of identifiers
           keywords are not allowed,
           no special character other then underscore, 
           2 consecutive underscores are not allowed, 
           identifiers are case sensitive, 
  • constants: it represents fix value for example: 1,3.14 etc.
  • string: it is a set of characters enclosed in double quotes
  • operators: it specifies which kind of operation is to be performed
           types of operators
           unirary operators
           binary operators
           ternary ioperators
       5. CHARACTER SET :  discussed earlier
       6.  DATA TYPES: data types specifies which type of data is used in program for example 
            char- 1 byte
            int - 2 byte
            float- 4 byte
            double- 4 byte
            void- 0 byte

 DECLARATION IN C

 Declaration consist of a data type followed by one or more variable ending with a semi column
for example: int a,b,c;

 EXPRESSIONS IN C

 It represents data & functions to be performed on that data

OPERATORS IN C

  1. Arithmetic operators: +, - , / , *
  2. Logically operators: &&, ||, !
  3. assignment operators: =
  4. relational operators: < , > , <=, >= ,==
  5. conditional operators: ?, :
  6. Bit wise operator:  it works on bit level
  7. sizeof operator: it is to determine the size of data type

Comments