C Programing

What is a programming language?

  • Programming Language is
  • A tool for instructing machines.
  • A means of communicating between programmers.
  • A means of controlling computerized devices.
  • A notation for algorithms.

Programming Domains

  • Scientific applications
  • Business applications
  • Artificial intelligence
  • Systems programming
  • Scripting languages
  • Special purpose languages

Machine Language

  • Machine language is the lowest-level programming language.
  • Machine languages are the only languages understood by computers.
  • A computer programming language consisting of binary or hexadecimal instructions which a computer can respond to directly.

Why Humans Don’t Use Machine Language

Machine languages are almost impossible for humans to use because they consist entirely of numbers.

Programmers, therefore, use either a high-level programming language or an assembly language.

An assembly language contains the same instructions as a machine language, but the instructions and variables have names instead of being just numbers.

Example of Machine language

Assembly Language

•A low-level symbolic code converted by an assembler.

•Assembly language is converted into executable machine code by a utility program referred to as an assembler like NASM, MASM, etc.

  • A processor understands only machine language instructions, which are strings of 1’s and 0’s.
  • However, machine language is too obscure and complex for using in software development. So, the low-level assembly language is designed for a specific family of processors that represents various instructions in symbolic code and a more understandable form.

Advantages of Assembly Language

  1. Having an understanding of assembly language makes one aware of −

•How programs interface with OS, processor, and BIOS;

•How data is represented in memory and other external devices;

•How the processor accesses and executes instruction;

•How instructions access and process data; •How a program accesses external devices.

2. The symbolic programming of Assembly Language is easier to understand and saves a lot of time and effort of the programmer.

3.It is easier to correct errors and modify program instructions.


4. Assembly Language has the same efficiency of execution as the machine level language. Because this is one-to-one translator between assembly language program and its corresponding machine language program.

Disadvantages of assembly language

•Mnemonics in assembly language are in abbreviated form and in large number, so they are hard to remember.

•Program written in assembly language are machine dependent, so are incompatible for different type of machines.

•A program written in assembly language is less efficient to same program in machine language.

•Mnemonics can be different for different machines according to manufacturers so assembly language suffers from the defect of non-standardization

Assembly is called a low-level programming language because there is (nearly) a one-to-one relationship between what it tells the computer to do, and what the computer does. In general, one line of an assembly program contains a maximum of one instruction for the computer.

 An Assembly program to read in two decimal inputs and print out their sum, in decimal

DATA SEGMENT

NUM2 DB ?

 NUM1 DB ?

RESULT DB ?

MSG1 DB 10,13,”ENTER FIRST NUMBER TO ADD : $“

 MSG2 DB 10,13,”ENTER SECOND NUMBER TO ADD : $“

 MSG3 DB 10,13,”RESULT OF ADDITION IS : $”

ENDS

In Assembly programming, the variable are all defined by bytes only.

DB – Define Byte  (Size – 1 Byte)

DW – Define Word  (Size – 2 Byte)

DD – Define Double word  (Size –  4 Bytes)

DQ – Define Quad word  (Size – 8 Bytes)

DT – Define Ten Bytes  (Size – 10 Bytes)

High Level Language

•A highlevel language is a programming language such as C, FORTRAN, or Pascal that enables a programmer to write programs that are more or less independent of a particular type of computer.

•Such languages are considered highlevel because they are closer to human languages.

Advantages of high-level languages

•Better portability (program runs on many CPUs)

•Richer data types and memory management

•Natural structures for expressing flow of control

•Much better support for software maintenance

•Much better support for software reuse

Translation Process of HLL

Compiler:  Translates an entire high-level language program into machine code before it is executed. Programming language like C, C++ use compilers.

Interpreter: Simulates a high-level language program, translating commands to machine code along the way, only as needed. Programming language like Python, Ruby use interpreters.

Features of C language

•It is a robust language with rich set of built-in functions and operators that can be used to write any complex program.

•The C compiler combines the capabilities of an assembly language with features of a high-level language.

•Programs Written in C are efficient and fast. This is due to its variety of data type and powerful operators.

•C is highly portable this means that programs once written can be run on another machines with little or no modification.

•Another important feature of C program, is its ability to extend itself.

C – Program Structure

A C program basically consists of the following parts − •Preprocessor Commands •Functions •Variables •Statements & Expressions •Comments

Sample Program

#include <stdio.h>

void main()

{

printf(“me love programming\n”);

printf(“You will love it too once ”);

printf(“you no the trick\n”);

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: