Posts

Showing posts from October, 2020

Compilation Stages for C Program

Image
Compilation process: Compilation is a process of converting human readable code into machine understandable code Compilation process is divided into 4 stages/parts: Pre-processor stage Translator stage Assembler stage Linker stage 1. Pre-processor stage First stage of compilation process. In this stage we will get pure C file or extended c file from our source file.         Pre-processor stage is responsible for: Including header files. Remove comments. Replace macros. Do conditional compilation. 2. Translator stage In this stage the code is converted into assembly language.        Translator tasks are: To generate assembly code. Check for any syntactical error. 3. Assembler stage: In this stage the assembly language code is converted into machine understandable code or object code. The content of object file is in binary format, to make this file readable you will have to disassemble it. 4. Linker stage: L...

Basic Structure of C Program

Image
 Structure of C Program: // single line Comments # pre-processor directives prototype declarations global variables main() function { local variable declaration statements ------      --------    ------- } user_defined_function1() { variable declaration statements -----         -----         ----- } Explanation: 1. Comments: Comments can be places anywhere in the program; generally used for documentation purposes or to increase the readability of the code. There are two types of comments 1. Single line comments        2. Multi line comments Single line comments starts with // followed by statement ex: // this is a single line comment Multi line comment start with /* and ends with */. ex: /* This is           multi line           comment */ 2. Preprocessors Directives:...

Getting started with C Language (2)

Image
Introduction: There are 2 nature of data: Constant and Variable 1)      Constants are the data that cannot be changed (example: PI is constant i.e. 3. 1418..) 2)      Variable is the nature of data that can be changed wherever required throughout the program. In any program we do lot of calculations. the results of these calculations need to stored in computer memory to retrieve these values when required in program. for easy retrieval and usage of these values the names are given to the memory cells called as variable names. Rules for constructing integer constants: Integer constant must contain one digit It must not have a decimal digit or value It can be positive or negative; if no sign mentioned default considered as positive. No commas and blanks are allowed in between the digits of number The integer range can be stored is -2147483648 to +2147483647 or -32768 to +32767 (depends on compilers) Valid integer constants: 400 -555 3089 -4096 ...

Getting started with C Language (1)

Character set in C language: Character set denotes the alphabets, digit or special symbol used to represent information. Alphabets A, B, C, ----, Z a, b, c ----, z Digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Special Symbols ~ ` ! @ # $ % ^ & * ( ) _ - + = | \ { } [ ] ; : ” ’ < > , . ? / Raw code : It is a code which can run without OS. example: .hex code(as it deployed in 8051 and it does not contain OS) Executable code : it is a code which cannot run without OS, OS is needed for this type of code. example: C code. Compilers: Compilers convert human readable code into binary code or machine understandable code. Types of compilers: Native compiler Cross compiler Native compiler: The compiler working in one environment and generating machine understandable code for same environment is called as native compiler. Example: Turbo C, Dev C++, etc. Cross compiler: The compiler working in one environment and gener...

Characteristics/Features of C Programming Language

Image
        I n-shorts: C is middle level language: User can use C on low level to do System programming (for writing Operating System) as well as to do High level Application(level) programming (Menu driven programs). Hence, it is excellent, efficient and general purpose language for most of the mathematical, scientific, software applications. C is procedural language: A procedural language is a programming, language that uses some order/syntax or a set of commands. Procedural languages are generally used by script and software programmers. Some of the other procedural languages example are C++, Java, FORTRAN. C is Portable language: A program written for one type of computer or operating system can run on another type of computer or operating system.   C is Structured language: the whole task can be splinted into smaller tasks thus dividing the whole task into smaller pieces called as functions. The functions are main building blocks of C language. Easy ...

History of C Programming Language

Image
History: " Dennis Ritchie " is known as the inventor of C language . Dennis Ritchie developed the C in 1970's in Bell laboratories, U.S.A. In 1972, Ritchie started to improve B(with Ken Thompson), which resulted in creating a new language C He kept most of the syntax of B Language and added the new features like data types and structures. C was developed between 1971-1973, containing both high level and low-level functionalities which can develop applications as well as Operating system Initially it was designed for programming in Operating system called UNIX. But now, entire UNIX OS and tools provide by it are written in C (using low level functionalities). It was developed to overcome the problems of previous languages such as B, BCPL, etc. which don't understand the datatypes and structures. Evolution of  Programming Languages: 1960- ALGOL(International Group) 1967- BCPL(Martin Richard) 1970- B(Ken Thompson) 1972/1973- Traditional C(Dennis Ritchie) 1978- K & RC...