Chemistry Learning

  • About
  • Physics
  • Chemistry
    • Colloids
  • Mathematics
    • Trigonometry
  • Biology
    • Carbohydrates
  • Information Technology
Information Technology10284

Programming Fundamentals

Algorithms are designed to solve a problem but cannot be directly implemented by the computer. A computer can only execute machine language ....

Table Of Content

Description

Algorithms are designed to solve a problem but cannot be directly implemented by the computer. A computer can only execute machine language instructions. Machine language instruction in binary coded language can be easily executed. To remember codes for different operations of a machine language is highly difficult. Thus, high-level languages can be used to implement algorithms. A compiler is software which converts a high level language to machine language. It converts the source program to object program.

High-Level language Translation

This can be shown by a diagram as follows:

High level language translation flow chart

Basic Programming language Preliminaries

Any programming language is divided into two distinct parts. These parts are described as:-

  • Syntax – They are the rules which are to be followed to form structures which are grammatically correct with respect to the programming language used.
  • Semantics – It assigns meanings to syntactic structures.

Writing basic programs

Writing a program to find area of a circle would be as

Formula to calculate Area of a circle is,

A = Πr2

Where r = radius of the circle

In ‘C’ language, multiplication operator is ‘* ’
Therefore Area (A)

A = Π * r * r      ….. (1)

Eqn (1) is called an Arithmetic statement in programming terminology

‘A ‘and ‘r’ are variables, values ‘Π ’ is a constant value 3.14.

Before execution (memory location)

Data Storage in Memory

After Execution

Area of Circle Flow Diagram

Program:

void main (  )
{
unit r; A
float A;
r = 1;
A = 3.14 * r * r;
}

To read and understand the program, comments are used. It describes the program.

Types of comments in ‘C’

a) Single line comment
b) Multiple line comment

a) Single-line Comment – It is preceded by double slash ( // ) and cannot exceed a line

Example: –

int a;         // declaration of an integer

b) Multi-line Comment – It consists of sequence of characters beginning with a forward slash ‘/’ asterisk combination (/*) that is treated as a single whitespace character by the compiler else it is ignored. It can inclined any combination of characters even ‘/n ‘excluding delimiter (*/).One should note that comments cannot be nested.

Example:-

/* Comments can also be given like this */.

May 1, 2009admin
Programming MethodologyColloidal Solution
Home Programming Fundamentals
May 1, 2009 Information TechnologyInformation Technology10285
Popular Posts
  • Adsorption Isotherm - 673204 Views
  • Langmuir Adsorption Isotherm - 560251 Views
  • Freundlich Adsorption Isotherm - 473892 Views
  • Colloidal Solution - 472279 Views
  • Adsorption - 467669 Views
  • Examples of Colloids - 398286 Views
  • Banking of Roads - 359611 Views
  • Rubber - 269456 Views
  • Colloidal Dispersions - 264366 Views
  • Difference between Lyophobic and Lyophilic - 246475 Views

Copyright © 2024 Xamplified | All Rights are Reserved