Wednesday, August 8, 2018

CREATING AND RUNNING A PROGRAM - PART III

3. Developing a program :

Developing a program refers to the process of writing the source code for the required application by following the syntax and the semantics of the chosen programming language. Syntax and semantics are the set of rules that a programmer to adhere while developing a program.

Before actually developing a program, the aim and the logic of the program should be very clear to the programmer. Therefore, the first stage in the development of a program is to carry out a detailed study of the program objectives. The objectives make the programmer aware of the purpose for which the program is being developed. After ascertaining the program objectives, the programmer needs to list down the set of steps to be followed for program development. The set of program development steps is called "algorithm". The programmer may also use a graphical model known as "flowchart" to represent the steps defined in the program algorithm.

          After the logic of the program has been developed either by an algorithm or a flowchart, the next step is to chose a programming language for actual development of the program code. There are a number of factors that should be taken into consideration while selecting the target programming language, such as performance and efficiency of the programming language, programmer's prior
experience with the language, etc. A programming language is typically bundled together with an IDE containing the necessary tools for developing, editing, running and debugging a computer program. For instance, Turbo C  and Turbo C++ is provided with a strong and powerful IDE to develop, compile, debug and execute the programs.

Suppose we are required to develop a program to add two numbers numbers so we need following algorithm to develop that program

STEP 1 : Declare a,b and c
STEP 2 : Initialize a and b values
STEP 3 : Store the sum of a and b values in c
STEP 4 : Display c value

Following program is the the sample program for addition of two numbers in C++

#include<iostream.h>
using namespace std;
int main()
{
int a,b,c;
a=5;
b=5;
c=a+b;
cout<<c;
return 0;
}


Output :
10

4. Running a Program :

After developing the program code, the next step is to compile the program. Program compilation helps to identify any syntactical errors in the program code. If there are no syntax errors in the source code, then the compiler generates the target object code. It is the machine language code that the processor of the computer system can understand and execute.

  Once the corresponding object code or the executable file is built by the compiler, the program can be run in order to check the logical correctness of the program and generate the desired output. The logical errors also called semantic errors which cause undesired results. After completion we will get the output after the run, the outpu of the above mentioned program is "10". If we need to compile the program we need to press Alt and F9 simultaneously.

No comments:

Post a Comment

Applying Software Development Method

To understand how software development method is applied, Consider a simple scenario where it is required to convert the temperature given ...