0% found this document useful (0 votes)
102 views55 pages

Sadigya Subedi BSC - It 1St Semester Enrolled in 2019: Programming Assignment Submitted by

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
102 views55 pages

Sadigya Subedi BSC - It 1St Semester Enrolled in 2019: Programming Assignment Submitted by

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 55

Programming Assignment

Submitted By:

Sadigya Subedi

BSc.IT 1st Semester

Enrolled In 2019

Submitted To:

Part 1 Niraj Khadka Sir

1. Present a mini research project both in the form of a report and as a presentation. You
will

Sadigya Subedi (HND / First Semester) 1


Part 1

1. Present a mini research project both in the form of a report and as a presentation. You

will need to explain what an algorithm is, with examples of their use, comparing their

efficiency against brute forcing, and how it will relate to the application development

process, down to the implementation in a suitable language. Research could be conducted

on your choice of algorithms, including sorting and searching data or

encryption/decryption, compression/decompression.

Note: Prepare a presentation for ten-minutes using Microsoft® PowerPoint® style

presentation to be presented to your colleagues. The presentation can include links to

performance data and a bibliography using the Harvard referencing system. You are

required to make effective use of headings, bullet points and subsections as appropriate.

Sadigya Subedi (HND / First Semester) 2


PART 1 REPORT

Submitted By:

Sadigya Subedi

BSc.IT 1st Semester

Enrolled In 2019

Submitted To:
ACKNOWL
Niraj Khadka Sir

Sadigya Subedi (HND / First Semester) 3


Acknowledgement

Firstly, as a student of ISMT College I would like to commemorate my college ISMT for
handing out this wonderful project for a student like me and many others to work on this
wonderful assignment and explore our level of understanding as well as our creativity. I would
also like to express my special thanks of gratitude to my teacher Mr. Niraj Khadka Sir as well as
all the teachers of Assignment Department who gave me the golden opportunity to do this
wonderful assignment which also helped me in doing a lot of Research and I came to know about
so many new things I am really thankful to them.

Secondly, I would also like to thank my classmates who helped me a lot in finalizing
this project within the limited time frame.

Sadigya Subedi (HND / First Semester) 4


Algorithm is a step by step procedure for solving a computational problem. Algorithm is
written in English like sentence, which discuss the solution for a problem understandable by any
person which is called pseudo code. An algorithm is used not only to solve complex and hard
problem but also is used to solve an easy problems as well. Hence, in programming term
algorithm is just a procedural outlined idea used to solve any problem that may arise while
carrying out the programming task in any programming language ( C, C++, JAVA) . Algorithm
is also used to overcome the chances of problems that may arise for the programmers during the
testing phase of the program.

Features Of Algorithm

 Finiteness
 Definiteness
 Input
 Output
 Effectiveness

Finiteness
Algorithm must get completed after finite number of steps.

Definiteness
An algorithm must be defined precisely step by step.

Input
An algorithm must have zero or more inputs.

Sadigya Subedi (HND / First Semester) 5


Output
An algorithm has one or more well defined outputs as well as the result should meet the desired
output.

Effectiveness
The operations to be performed in the algorithm must sufficiently basic that they can in
principle be done exactly and in a finite length of time.

Advantage Of Algorithm
There are different disadvantage of algorithm. Some of them are as follows :

 Easy and Efficient Coding


The algorithm act as blueprint during program development
 Program Debugging
Debugging is identifying the logical errors in algorithm /program. Algorithms help in
debugging so that we can identify the logical errors easily.
 Effective Analysis: By using the help of the algorithm , problems can be analyzed
strongly. There can be number of algorithms for solving the given problem.

Disadvantage Of Algorithm
There are different disadvantage of algorithm. Some of them are as follows :

 Complex Logic
The flowchart becomes complex to show different types of branching and looping.
 Modification in the program
If any types of changes had to be applied in the middle while preparing the algorithm
and flowchart it has to be entirely rewritten which takes a lot of time.
 Time consuming
Algorithm makes easier for the developer to develop a program but it also takes a lot of
time while preparing the algorithm for big task.

Example of Algorithm
We use algorithm while developing the program as well as we use the algorithm in our daily
lives too. Here, are the different examples about how we use algorithm while developing a
program as well as in our practical life.

Sadigya Subedi (HND / First Semester) 6


Practical Life Algorithm

Here is an example to prepare a cup of boil water. To boil the water we use a fix procedure and
algorithm as described below :

1. Take a bowl.
2. Add some water .
3. Switch on the gas.
4. Soon
Here, the above mentioned process i.e. 1 to 4 respectively are the algorithm to boil
water. Therefore, the algorithm process is also applicable in the practical life as well
as the programming life.

Programming Algorithm
 Step 1- Start the program.
 Step 2- Read / input the number.

 Step 3- if n%2==0 then number is even.


 Step 4- else number is odd.
 Step 5- display the output.
 Step 6- Stop the program.

Relation Of Algorithm with Application Development


The duty of programmer is to make logic on how to create the the program assign by the client
since computers aren’t able to think and execute the code by itself. Hence, to make the logic on
how to develp the program various algorithm are made and hence these algorithm are executed
on different programming language by considering it as a blueprint for the progression of the
program or the assign project by the user.

Outline Process Of Application


The outline process of application is a framework of the application that the development team
use to design, develop and test to produce high-quality software in a systematic way which meets
the requirement of the customer in provided time and within a low budget. Outline process of
application in general also known as SDLC. There are different stages/process involve in the
development of typical software development lifecycle. The different stages are as follows :-

Sadigya Subedi (HND / First Semester) 7


 Stage 1: Planning and Requirement Analysis

 Stage 2: Defining Requirements


 Stage 3: Designing the Product Architecture
 Stage 4: Developing the Product/Implementing code in design
 Stage 5: Testing the Product
 Stage 6: Deployment in the Market and Maintenance

Stage 1: Planning and Requirement Analysis


This is the first step for the process of an application. For the process of an application
planning is done first because planning focuses on the scope of the project. The output of the
planning phase includes project plan, estimated time of completion/schedule, cost estimation and
different requirements.
In this, the requirements are collected from the clients. People involved in this phase are the
senior levels such as managers, stakeholders, subject matter experts etc. During this phase, the
team will also discuss the opportunities and risks of capturing or conducting the project.

Stage 2: Defining Requirements


Once the requirement analysis is done the next step is to clearly define and document the
product requirements and get them approved from the customer/clients. Concerning with the
clients and satisfying the requirements of the client is an important part of the application
developing process. Hence, the application developing process is productive in that case if it
satisfies the necessities/requirements of the client.
Here, SRS (Software Requirement Specification) document is used which consists all the
product requirements that are required to be designed and developed during the project phase.

Stage 3: Designing the Product Architecture


After analyzing the client needs and meeting the required specifications and requirements third
step is to design the application. Here, more than one design approach are made for the product
architecture to make the client satisfied and documented in a DDS - Design Document
Specification. This Design Document Specification is reviewed by the managers, stakeholders,
subject matter experts and based on various parameters and risk management, product validness,
design module, time constraints, budget the best design approach is selected for the product.

Stage 4: Developing the Product/Implementing code in design


In this stage, the different types of programming language are used like Java, C, C++, etc. in
order to develop the client product by implementing the code. The programming language is

Sadigya Subedi (HND / First Semester) 8


chosen with respect to the type of software that is being developed. The principle part is coding,
if the coding isn’t done properly then the application doesn’t respond at the point. So coding is
most significant for a development of an application.

Stage 5: Testing the Product


After the development of the product, testing is done in order to check that the application is
responding to the user or defects are reported, tracked, in the coding of the application inorder to
reach the quality of standard of the software. Hence, testing is done before releasing the product
to the client and it is only released to the client after finishing the testing process in order to
minimize the risk because there may be some short of defect in the application making process in
some instances.

Stage 6: Deployment in the Market and Maintenance


For the competition in the market time to time maintenance is done as indicated by the
feedback of the customer But before releasing in the market limited edition is released in order to
get the feedback from the customer to release the application in huge amount in the market. The
limited edition is released in order to test the application or software in the real world and to get
the feedback from the real clients in order to know what the developer can still maintain before
releasing the application in huge amount in the market.

Development Environment
The term development environment is the set of process used to create and test the program or
software product to maximize productivity and efficiency for the developer. The purpose of a
development environment is to have a place for a developer to test anything they want without
worrying about it affecting any end-users or content Some of the examples of development
environment are as follows :-

 Microsoft Visual Studio


 Notepad++
 Android Studio

Existing Development Environment


There are different types of development environment for different programming language
some of them are described below :-

Microsoft Visual Studio


Microsoft Visual Studio is an development environment used to develop computer program,

Sadigya Subedi (HND / First Semester) 9


websites, mobile apps etc which is developed by Microsoft corporation. Microsoft Visual Studio
provides support for 36 different programming languages. It is available for Windows as well as
for macOS. There are three editions of Microsoft Visual Studio which are as follows :

 Community
 Professional
 Enterprise

Android Studio
Android Studio is the official integrated development environment for Google's Android
operating system. It is available for download on Windows, macOS and Linux based operating
systems. It is developed in coordination of Google and JetBrains. It is designed specially for
Android Development. It is currently the most widely used Development Environment. Android
Studio allows to see any visual changes that we make to our app in real-time, and we can also see
how it will look on a number of different Android devices, each with different configurations and
resolutions, simultaneously.

JCreator
JCreator is an development environment for Java, consisting of tons of features and
functionality in a simple user interface which is suitable for both amatuer and professional
developers. Unlike most Java IDEs which helps typically for writing in Java, JCreator is written
entirely in C++ to support special speed, sharpness and cleverness. It is fully customizable user
interface. It also has syntax highlighting feature by which the different code are displayed in
different colors and font according to the category of the term.

Eclipse
Eclipse is an open source community of tools, projects offering several popular IDEs including
the cloud IDEs and desktop IDEs. Eclipse support our development work with any language
which means that Eclipse provides a tool that meets our needs. It is free of cost. Eclipse is
written mostly in Java and its primary use is for developing Java applications.

In the above-mentioned editions of Microsoft we have used Microsoft Visual Studio


Community edition development environment.

Reasons for using the Microsoft Visual Studio Community edition

 Automatically checks for errors to ensure top quality code.


 Maintain a smooth development cycle.
Sadigya Subedi (HND / First Semester) 10
 It has customizable options where the developer are able to publish their own extension.
 Variety of tools, controls, and templates available from Microsoft, partners, and the
community.
 Microsoft Visual Studio Plan, execute, and monitor your entire testing effort.
 Write code accurately and efficiently without losing file context.

Programming Language
A programming language is a set of commands, instructions, notation designed to connect
instructions to a machine which is used to create an application/software program. Programmers
use language to write the code which are called high level languages. There are different types of
programming languages used which are described below :-

 HyperText Markup Language


 JavaScript
 C Language
 C++
 C#
 PHP
 Python

HyperText Markup Language


HTML stands for Hyper Text Markup Language which is the standard markup language for
creating Web pages. We can code your entire website offline, storing it all on our computer, and
then just transfer all the files onto the web. Browsers take that HTML content and translate it into
what we see on your device’s screen.

Example of JavaScript code


Below is an example of simple page. This is the code which is used to make the page.
This is the code used to make the page:

<HTML>

<HEAD>

<TITLE>Your Title Here</TITLE>

</HEAD>

Sadigya Subedi (HND / First Semester) 11


<BODY BGCOLOR="FFFFFF">

<CENTER><IMG SRC="clouds.jpg" ALIGN="BOTTOM"> </CENTER>

<HR>

<a href="http://somegreatsite.com">Link Name</a>

is a link to another nifty site

<H1>This is a Header</H1>

<H2>This is a Medium Header</H2>

Send me mail at <a href="mailto:[email protected]">

[email protected]</a>.

<P> This is a new paragraph!

<P> <B>This is a new paragraph!</B>

<BR> <B><I>This is a new sentence without a paragraph break, in bold italics.</I></B>

<HR>

</BODY>

</HTML>

JavaScript
JavaScript is the programming language of HTML and the Web. JavaScript is easy to learn.
JavaScript is used mainly for enhancing the interaction of a user with the webpage. Client–side
JavaScript has expressly been developed for use in a web browser in conjunction with HTML
pages. This has certain consequences for security. JavaScript only works on things that are in
HTML pages or part of the browser.

Example of JavaScript code


The following is a example of a rock-paper-scissors application code using HTML and
JavaScript. The <SCRIPT> tag contains a JavaScript function called playRoshambo, which is
triggered by the onclick event of the user clicking on anchor link which contains the text paper.
The result of playing the game is displayed within the <div> tag named results.

<script>
playRoshambo = function(clientGesture) {
//server always chooses rock
if (clientGesture=='rock') {
Sadigya Subedi (HND / First Semester) 12
result = "tie";
}
if (clientGesture=='paper') {
result = "win";
}
if (clientGesture=='scissors') {
result = "lose";
}
document.getElementById('results').innerHTML = result;
}
</script>

Which one will it be?<br/>


<a href="#" onclick="playRoshambo('paper')"> paper </a>
<div id="results"></div>

C Language
C was developed at Bell Labs by Dennis Ritchie for the Unix Operating System in the early
1970s. Ranked among the most widely used languages, C has got the compiler for most of the
computer systems and also has influenced many knowable programming languages like C++. C
belongs to the structured, procedural paradigms of languages. Many later developed languages
have borrowed features directly or indirectly from the C language. Like the syntax of PHP, Java,
JavaScript, and many other languages are based on C language.

Example of C language code


Here is an example about how to display Hello Sadigya.

#include<stdio.h>
int main()
{
printf("Hello Sadigya, I am C");
}

C++
C++ was also developed at Bell Labs by Bjarne Stroustrup, and is an extension of the C

Sadigya Subedi (HND / First Semester) 13


language. C++ belongs to the, object-oriented programming (OOP) paradigms of languages. C++
is considered to be an intermediate-level language, as it encapsulates both high- and low-level
language features. A function is the minimum requirement for a C++ program to run. C++
supports the four primary features of OOP: encapsulation, polymorphism, abstraction, and
inheritance.

Example of C++ language code


Here is an example of C++ language code on how to swap two numbers.

#include <iostream>

using namespace std;

int main()

int a,b,c;

cout << "Enter value of a: ";


cin >> a;

cout << "Enter value of b: ";


cin >> b;

c=a;

a=b;

b=c;

cout<<"After swaping a: "<< a << " b: " << b;

return 0;

C#
C# is a general-purpose, modern and object-oriented programming language pronounced as C
Sharp. It was developed by Microsoft and uses Microsoft's .Net platform. C sharp was designed
by Anders Hejlsberg, and the team is led by Mads Torgersen. The recent version is 8.0, which
was released on 2019 alongside Visual Studio 2019 version. The core syntax of C# language is
similar to that of other C-style languages such as C, C++ and Java.

Sadigya Subedi (HND / First Semester) 14


Example of C# language code

PHP
PHP is a widely-used open source general-purpose scripting language that is especially suited
for web development and can be embedded into HTML. PHP can create, open, read, write,
delete, and close files on the server. PHP runs on various platforms like Windows, Linux, Unix,
Mac OS X, etc. PHP can add, delete, modify data in our database

Example of PHP language code

<html>
<head>
<title>Example</title>
</head>
<body>

<?php
echo "Hi, I'm a PHP script!";
?>

</body>
</html>

Python
Python is a popular programming language. It was created by Guido van Rossum, and released
in 1991. It is used for web development (server-side), software development, mathematics,

Sadigya Subedi (HND / First Semester) 15


system scripting. Python can be used to handle big data and perform complex mathematics.
Python has a simple syntax similar to the English language. Python works on different platforms
Windows, Mac, Linux, etc.

Example of Python language code


Here is an example of Python language code which adds two numbers

num1 = 1.5
num2 = 6.3

# Add two numbers


sum = float(num1) + float(num2)

# Display the sum


print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))

Language we have used


The language that we have used is C#. We have used this programming language to build an
application on Microsoft Visual Studio 2019 Community edition. We used this language because
It gives us an excellent programming foundation since it's similar to other C-type languages like
C, C++, and Java.
It is simple and Modern programming language. C# language is rich in the library so it
provides a lot of inbuilt functions that makes development simple, fast and easy. Usually it is
much more efficient than java and runs faster. It has got formalized concept of get-set method, so
the code becomes more understandable. C# has an efficient system to erase all the garbage
present on the system also it doesn’t create mess in the system and the system do not get hanged
during execution. We can buy support from the Microsoft in C# (.NET framework) unlike Java
where community is our support. So if things get wrong then we can solve our issues with the
support of Microsoft. C# has a major advantage of a strong memory backup. There would be no
problem of the memory leak and other such type of problems in the C# as it happens in the case
of C++ language. In this case C# has a very clear edge on all other languages. Our application
will run well only if our device has installed the NET framework. This is the most important
requirement for the C#, also this could be an opportunity for the young programmers like us to
get trained with .NET framework

Platform Environment
A platform environment is the environment in which a piece of software is executed. There are

Sadigya Subedi (HND / First Semester) 16


different software development platforms like cross platform software, perl, Symbian , Linux,
Microsoft Azure Web series,

The platform environment of the language that we have used is Microsoft development .Net
platform. For the .net framework, we have used .NET Framework 4.6 which was installed as
default. The .NET Framework is object oriented We used this platform because it provides
opportunities available for software developers, alongside the Azure cloud and other services. It
has different kinds of tools that people can use easily to create any kind of applications as well as
it also has a tool for connecting various applications, which makes it possible to have data from
one system show up in another. The main reason we have used the .NET Framework because it
is object-oriented and supports C# and helped us in making of the “Assignment Management
System”.

The above mentioned is the .NET framework that we have used in building an application.

Figure 4: .NET Framework Installed in PC

Sadigya Subedi (HND / First Semester) 17


a. Hardware Platform
They include line of hardware devices.

b. Mobile Platform
They include hardware/software devices for developing mobile applications.

c. Client/Server Platform
They are the platform for client/server software’s such as web browsers

d. Software Platform
They are the platform where computer software’s work. They can be Operating Systems or
development environment.

e. Cloud Platform
Platform for deploying cloud services

f. Third Party Platform


Platform for the third-party software like social media etc.

M1
Determine the steps taken from writing code to execution.
The Code execution process include following steps

 Source code
 Pre-processor
 assembler
 Linker

Sadigya Subedi (HND / First Semester) 18


 Loader
 Memory

Diagram of Code Execution

Source Code
Source code is the fundamental component of a computer program that is created by a
programmer. It can be read and easily understood by a human being. When a programmer types
a sequence of C programming language statements into Windows Notepad, for example, and
saves the sequence as a text file, the text file is said to contain the source code. It contains
declarations, instructions, functions, loops and other statements, which act as instructions for the
program on how to function. Programs may contain one or more source code text files, which
can be stored on a computer's hard disk, in a database, or can be printed in books of code.

Pre-processor
Preprocessing is the first step of the language processing system. Language processing system
translates the high level language to machine level language (i.e. to the form that can be
understood by machine). Preprocessors are programs that process our source code before

Sadigya Subedi (HND / First Semester) 19


compilation.
There are 4 main types of preprocessor directives:
1. Macros
2. File Inclusion
3. Conditional Compilation
4. Other directives

Macros
A macro is a fragment of code which has been given a name. Whenever the name is used, it is
replaced by the contents of the macro which means that whenever this name is encountered by
the compiler this compiler replaces the name with the actual piece of code. It can also be called
as text substitutions. The ‘#define’ directive is used to define a macro.

File Inclusion
This type of preprocessor directive tells the compiler to include a file in the source code
program. There are two types of files which can be included by the user in the source code
program :-

 Header File or Standard files


 User defined files

Header File or Standard files


These files contains definition of pre-defined functions like printf(), scanf() etc. These files
must be included for working with these functions. Different function are declared in different
header files.
Syntax : #include<file_name>

User defined Files


When a program becomes very large, it is good practice to divide it into smaller files and
include whenever needed. These types of files are user defined files. These files can be included
as :

Syntax : #include”filename”

Conditional Compilation
Conditional Compilation directives are type of directives which helps to compile a specific
portion of the program or to skip compilation of some specific part of the program based on

Sadigya Subedi (HND / First Semester) 20


some conditions. This can be done with the help of two preprocessing commands ‘ifdef‘ and
‘endif‘.

Syntax : #ifdef macro_name

statement1;

statement2;

statement3;

statementN;

#endif

Other directives
Apart from the above directives there are two more directives which are not commonly used.
These are:

 #undef Directive
 #pragma Directive

#undef Directive: The #undef directive is used to undefine an existing macro. This directive
works as:
#undef LIMIT

#pragma Directive: This directive is a special purpose directive and is used to turn on or off
some features. This type of directives are compiler-specific i.e., they vary from compiler to
compiler.

Assembler
An Assembler is a program that translates human readable symbols mostly three letter symbols
into binary data that can be executed by a processor. The output generated by assembler is the
object code or machine code understandable by the computer. Assemblers are classified based on
the number of times it takes them to read the source code before translating it; there are both
single-pass and multi-pass assemblers.

Linker
After the compiler creates one or more object files, then the job of the linker is in three process.
Sadigya Subedi (HND / First Semester) 21
In First, to take all the object files generated by the compiler and combine them into a single
executable program.
Second, in addition the linker also is capable of linking library files. A library file is a
collection of precompiled code that has been “packaged up” for the reuse in other programs.
Thirdly, the linker makes sure all cross-file dependencies are resolved properly. For example,
if we define something in one .cpp file, and use it in another .cpp file, then the linker connects
the two .cpp files together. If the linker is unable to connect a reference to something, we will get
a linker error, and the linking process will abort. We need to put all the modules together. This is
the job of the linker.

Loader
The loader is a component of an operating system that carries out the task of preparing a
program or application for execution by the OS. It does this by reading the contents of the
executable file and then storing these instructions into the RAM, as well as any library elements
that are required to be in memory for the program to execute. The reason of splash screen
appearing before the start of the program, often showing what is happening in the background is
what the loader is currently loading into the memory. When all of that is done, the program is
ready to execute.

Memory
The executable code is sent to loader which loads it into memory and then it is executed. The
memory acts as source to store the executable output which is currently being displayed over the
screen of the computer. After execution, output is sent to console.

Q. Explain the characteristics of procedural, object oriented and event driven


programming, conduct an analysis of a suitable Integrated Development Environment
(IDE)

There are a number of alternative approaches to the programming process, referred to


as programming paradigms. The different programming paradigms are :-

 Procedural Programming
 Object Oriented Programming
 Event-Driven programming
In this task,, we are going to discuss about explanations of what procedural, object

Sadigya Subedi (HND / First Semester) 22


oriented and event driven paradigms are and each of their characteristics and the
relationship between them.

Procedural Programming
A programming language which uses list of instructions or procedures to perform a task is
known as procedural programming. In other words, it is a imperative language where execution
is based on the statements and step by step procedure. The code of the program executes line by
line with logical steps, it follows the top to bottom approach, the code is written first execute
with some conditions. The conditions are decided by the procedure calls. For example, if there
are two functions in the program the main function executes fist and the code will execute top to
bottom. Some of the examples of Procedural Programming includes BASIC, C, FORTRAN,
PASCAL, COBOL, etc.

Characteristics Of Procedural Programming


It focuses on process rather than data.

 It takes a problem as a sequence of things to be done such as reading, calculating and


printing. Hence, a number of functions are written to solve a problem.
 A program is divided into a number of functions and each function has clearly defined
purpose.
 Most of the functions share global data.
 It has ability to maintain program flow.
 Data moves openly around the system from function to function.

Features Of Procedural Programming

 Predefined functions

 Local variables

 Global variables

 Parameter passing

 Modularity

 Procedures

 Programming libraries

Predefined functions
Examples of pre-defined function such as "System.out.println", can be used as a function that
is already within a programming language, this grants easy work for programmers. This is

Sadigya Subedi (HND / First Semester) 23


because it can be written as "System.out.println" instead of having to use lines of code to get the
same outcome if they weren't actually a thing.

Local variables
A local variable is a variable that is declared in the body of a method that you make. They you
can use that variable only in the method you made. If you have other methods in the class they
will not even be aware that the variable even exists. Here is an example of a program using a
local variable :-

Public class HelloWorld


{
String MyName;
MyName="Sadigya";
System.out.println(MyName);
This is an example of a local variable.

Global Variables
Variables that are declared outside a block are known as Global Variables. Global variables
have a program scope, which means they can be accessed anywhere/everywhere within the
program. The only way they can be destroyed is when the program ends as they are global.
Unlike local variables Global variables can be accessed anywhere throughout the program. A
global variable maybe used when we want to declare a variable that needs to be accessed by all
parts of our program.

Parameter passing
A parameter is a type of variable that you can pass into a function. Variables are the listed parts
of each methods declaration. Parameter passing allows variable values to be passed through to
the program which will handle it with a procedure.

Modularity
Modularity is a general concept which applies to the development of software. It allows
individual modules to be developed, in many cases this is done with a standardized interface to
allow modules to work and communicate properly. Each module works independent to each
other. Modularity is a software technique that shows that separating the functionality into
individual, interchangeable modules, each which allows it to execute the specific thing it is
designed to to do. These all combine as different tasks to achieve an overall goal.
Sadigya Subedi (HND / First Semester) 24
Procedures
Procedures are just small programs. The purpose of a procedure is to help a programmer avoid
repetition. A procedure start off with a begin and end up with end. In the Procedural
Programming Language the program that has them in, will follow the procedures step by step.
The program does exactly what it is told to do in the order that has been set by the programmer.

Programming libraries
Programming libraries are a collection of pre-built codes , routines, sub-routines, classes and
values which can be used at any time by the program and it's users. There are many Libraries in
programming. They each contain some unique functions and subroutines for a specific program.

Limitations of Procedural Programming Language


One limitation of Procedural Programming is that if a large program is being written using it,
anyone that hasn’t created the code will find it difficult to understand because the code will go
back and forth and to understand one part of the code we may have to scroll down thousands of
lines to find the part of code that’s related to it. Most of the code links to each other, and if we
modify one part of our code, the chances are this could affect multiple parts of our code. As we
can see, this will have a multiplier effect, so there could be thousands of lines that we have to
change to achieve one small modification on the code being written. One final limitation of
Procedural Programming is that it is very hard to relate to real world objects, unlike event-driven
programming. For this reason, procedural programming is not used in objects like kettles, fans
and microwaves.

Example of coding using Procedural Programming Language


Here is an example of coding using Procedural Programming Language.

Sadigya Subedi (HND / First Semester) 25


Here is the code on how many times does the user like to displayed the name he/she likes on
the screen of an application. The user can only enter 20 character name because we have already
declared char name [20] and below is the output of the coding we code above.

Hence, this is an example of Procedural Programming Language.


Basic I/O

Control Statement
A control statement is a statement that determines whether other statements will be executed or
not. Hence, it means that this statement looks after whether to execute the statement during the
execution process or not.

 An if statement decides whether to execute another statement, or decides which of two


statements to execute.

Sadigya Subedi (HND / First Semester) 26


 A loop decides how many times to execute another statement. There are three kinds of
loops:

o while loops test whether a condition is true before executing the controlled
statement.

o do-while loops test whether a condition is true after executing the controlled
statement.

o for loops are (typically) used to execute the controlled statement a given number
of times.

 A switch statement decides which of several statements to execute.

Looping
In programming, loop is a sequence of instruction’s that is continuously repeated until a certain
condition is reached and the process of loop is known as looping.
Types of Loops
A loop is classified into two types:

 Entry controlled loop


 Exit controlled loop

Entry controlled loop


In an entry controlled loop, a condition is checked before executing the body of a loop. It is
also called as a pre-checking loop.

Exit controlled loop


In an exit controlled loop, a condition is checked after executing the body of a loop. It is also
called as a post-checking loop.

'C' programming language has three types of loop :-

 The while loop


 The do-while loop
 The for loop

Sadigya Subedi (HND / First Semester) 27


Example and Syntax of The while loop
Here, is an example and Syntax of the while loop.
Syntax

while (condition) {

statements;

Here is the output of the program using while loop.

Example and Syntax of The Do while loop


Here, is an example and syntax of Do while loop.
Syntax

do {

statements

} while (expression);

Sadigya Subedi (HND / First Semester) 28


Here is the output of the program using Do while loop.

Example and Syntax of For loop


Here, is an example and syntax of For loop.

Syntax
for (initial value; condition; incrementation or decrementation )

statements;

Sadigya Subedi (HND / First Semester) 29


Here is the output of the program using while loop.

Array
An array is a collection of fixed number of components (elements), where all of components
have same data type. There are two types array which are as follows :-

 One-dimensional array
 Multi-dimensional array

Example and Syntax Of Array


dataType arrayName[arraySize];

Sadigya Subedi (HND / First Semester) 30


Here is an example of Array.

Here is the output the program which have been coded above.

One-dimensional array
A One dimensional array is a array in which components are arranged in linear form. It is also
known as single dimension array. A one-dimensional array has a list of variables with the same
data type.

Multi-dimensional array
A Multi-dimensional array is a array in which components are arranged in tabular form.
The Multi-Dimensional array is 'array of arrays' having similar data types.

Structure
A structure is used to represent information about something complicated than a single
number, character, or Boolean can do (and more complicated than an array of the above data
Sadigya Subedi (HND / First Semester) 31
types ) For example, a Student can be defined by his or her name, gpa, age, Student ID, etc. Each
of these pieces of information should be labeled with an easily understood descriptive title, and
then combined to form the structure.

Example and Syntax Of Structure


struct structureName

dataType member1;

dataType member2;

...

};

To reference a field of a structure, we use a "dot" between the name of the variable containing
the structure, and the name of the field of the structure.

The output of the program is mentioned below.

Sadigya Subedi (HND / First Semester) 32


Pointer
Pointers are special variables that are used to store addresses rather than values. A pointer is
used to access the memory location. There are various types of pointers such as a null pointer,
wild pointer, void pointer and other types of pointers.

Example and Syntax Of pointer


The syntax of pointer is int* p; Here, we have declared a pointer p of int type. Here, int means
as an integer. We can also declared pointers as int *p1; int *p2; .

The output of the code is mentioned below.

String
A string is a data type used in programming, such as an integer and floating-point, but is used
to represent text rather than numbers. It is comprised of a set of characters that can also contain
spaces and numbers. For example, the word "sadigya" and the phrase "sadigya is a student" are
both strings. Even the numbers "12345" could be considered a string, if specified correctly.
Typically, programmers enclose strings in quotation marks for the data to recognized as a string
and not a number or variable name.
Example and Syntax Of pointer
char str_name[size];
Here is an example of String

Sadigya Subedi (HND / First Semester) 33


The output of the program is below.

Function
A function is a block of statements that performs a specific task. A programmer can create
their own functions. Once the function is properly described by the programmers, it can be used
like the predefined functions.
Example and Syntax of the function
returnType functionName(type1 argument1, type2 argument2, ...)

//body of the function

The example of the function is given on user defined function.

There are two types of functions :-

 Predefined standard library functions


 User Defined functions

Predefined standard library functions


These are the functions which already have a definition in the header files (.h files like stdio.h)
so we just call them whenever there is a need to use them. The some of the examples of such
type of functions are puts(), gets(), printf(), scanf() etc.

User Defined functions


The functions that we create in a program are known as user defined functions. Here, the user

Sadigya Subedi (HND / First Semester) 34


should declare the function with appropriate prototype before calling and defining the function.
Here is an example of user defined function.

Below is the output of the above coded program.

Hence, this is the example of the user defined function.

File Handling
File Handling concept in C language is used for store a data permanently in computer. Using
this concept we can store our data in Secondary memory (Hard disk). All files related function
are available in stdio.h header file.

For achieving file handling in C we need follow following steps

Sadigya Subedi (HND / First Semester) 35


 Naming a file
 Opening a file
 Reading data from file
 Writing data into file
 Closing a file
Functions use in File Handling in C:

1. open()
To create a file

2. close()

To close an existing file

3. getc()

Read a character from a file

4. putc()

Write a character in file

5. printf()

To write set of data in file

6. scanf()

To read set of data from file.

7. getw()

To read an integer from a file

8. putw()

To write an integer in file

Object oriented programming language


Object-orientated programming breaks down a program into objects. Object-orientated
programming is different to procedural programming as it follows a different structural format to

Sadigya Subedi (HND / First Semester) 36


procedural programming. Object-orientated programming was developed to deal with the
complexities of more advanced systems when procedural programming couldn’t address the
difficulties that the system faced.
Some examples of Object Oriented Programming Languages are;PHP5, C++ and Fortran 2003.

Features of Object oriented programming language


Some

 Data encapsulation
 Class and Object
 Inheritance and its Types
 Polymorphism
 Abstraction
 Overloading

Data encapsulation
Encapsulation is the grouping of data and methods which work on that data together and provide
the user an interface through which the user can accomplish tasks without getting into the details
of implementation. Data encapsulation, sometimes referred to as data hiding. While working
with procedural languages, it is not always clear which functions work on which variables but
object-oriented programming provides you framework to place the data and the relevant
functions together in the same object.

Class and Object


When we define a class, we define a blueprint for an object. Class doesn't actually defines any
data, but it defines what the class name means, i.e, what an object of the class will consist of and
what operations can be performed on such an object.
An Object is an identifiable entity with some characteristics and behaviour. An Object is an
instance of a Class. When a class is defined, no memory is allocated but whenan object is created
memory is allocated.

Inheritance and its Types


The capability of a class to derive properties and characteristics from another class is
called Inheritance. Inheritance is one of the most important feature of Object Oriented
Programming. The child or derived class inherits all the features of its parent or base class, and is
free to add features of its own. In addition, this derived class may be used as the base class of an

Sadigya Subedi (HND / First Semester) 37


even more specialized class. There are two types of class in inheritance. The two types of class
are :-

 Sub Class
 Super Class

Sub Class: The class that inherits properties from another class is called Sub class or Derived
Class.
Super Class:The class whose properties are inherited by sub class is called Base Class or Super
class.

There are different types of inheritance which are as follows :-

Single Inheritance : In single inheritance, a class is allowed to inherit from only one class. i.e.
one sub class is inherited by one base class only.
Syntax :
class subclass_name : access_mode base_class

//body of subclass

};

Multiple Inheritance : Multiple Inheritance is a feature of C++ where a class can inherit from
more than one classes. i.e one sub class is inherited from more than one base classes.

Syntax :

class subclass_name : access_mode base_class1, access_mode base_class2, ....


Sadigya Subedi (HND / First Semester) 38
{

//body of subclass

};
Here, the number of base classes will be separated by a comma (‘, ‘) and access mode for every
base class must be specified

Multilevel Inheritance: In this type of inheritance, a derived class is created from another
derived class.

Hierarchical Inheritance: In this type of inheritance, more than one sub class is inherited from
a single base class. i.e. more than one derived class is created from a single base class.

Hybrid (Virtual) Inheritance: Hybrid Inheritance is implemented by combining more than one
type of inheritance. For example: Combining Hierarchical inheritance and Multiple Inheritance.

Polymorphism
Polymorphism this is existing features of object oriented programming. It provides concept of
same name or different behavior. Poly refers to many. That is a single function or an operator
functioning in many ways different upon the usage is called polymorphism.

Abstraction
Data abstraction refers to, providing only essential information to the outside world and hiding
their background details. For example, the Hyundai invented a car in which we can turn the
steering wheel to automatic. As a user, we do not really know what happens in the inner
workings of the car, we just use the interface provided to us to get the work done. The complex
implementation details are hidden from us by using an interface. This is called as data abstraction
(the process of hiding complexity).

Overloading
The concept of overloading is also a branch of polymorphism. When the exiting operator or
function is made to operate on new data type, it is said to be overloaded.

Example of Object Oriented Programming Language


Here is an example of Object Oriented Programming Language.

Sadigya Subedi (HND / First Semester) 39


Output of the program is shown below.

Event driven programming language


Event-driven programming is the program where the application responds to an event which
has happened due to the input of the user. This type of program is different from other
programming paradigms because the system of the event driven programming does not respond
to the structure of the program though the structure of the program can follow the similar
technique to OOP. Event-driven program follows the activity of the user to analysis the flow of
the program and requires the designer to write event procedures to respond to the input of the
user.

Features
Service Oriented
Sadigya Subedi (HND / First Semester) 40
Service focused is a key features in event-driven programming that used to create programs that
are created for services and it takes does not slow down the computer as service oriented only
take in little of the computer control vitality and usually services run in the backdrop of OS.

Time Driven

In event motivated programming, time influenced is a paradigm, from the code that runs on a
period trigger, time motivated can be considered a specific code that works on a specific time,
which could be once one hour, once a week or once a month, this means from the pre-set to do
activity.

Event Handlers

Event handlers is a type of function or method that run a specific action when a specific event is
prompted. For example, maybe it's a button that whenever consumer click it, it'll display a note,
and it'll close the subject matter when user click the button again, this is an event handler.

Trigger Functions

Trigger functions in event-driven coding are a functions that make a decision what code to
perform whenever there are a specific event occurs, which are being used to select which event
handler to use for the function when you can find specific event occurred.

Events

Events include mouse, computer keyboard and user interface, which events have to be triggered
in this program in order to happen, that mean user have to interacts with an object in this
program, for example, click a button by a mouse, use computer keyboard to choose a button and
etc.

Limitation
The limitation of Event Driven Program is it can get very hard to understand by the other
programmer. Event driven programs is less logical as it doesn’t contain the algorithm or
procedure like the other programming paradigms, which makes it more difficult understand and
write. Other limitation is that it can require quite a lot of processing power as it will have to
refresh instantly to see if any changes has been made in the GUI . If any changes has been made
to the program then in that case the program will have an extra task to carry out the code for the
Sadigya Subedi (HND / First Semester) 41
certain action for which the code has been made or changed, which will take more processing
time.

IDE Define and Example


An integrated development environment (IDE) is a software application which provides tools
and facilities to the users to make them easier to develop and debug other pieces of software.
Some of the examples of IDE are as follows :-

 NetBeans
 Microsoft Visual Studio
 Eclipse

Benefits of IDE
Some of the benefits of using Integrated Development Environment are as follows :-

 Automatically checks for errors to ensure top quality code.


 Maintain a smooth development cycle.
 It has customizable options where the developer are able to publish their own extension.
 Variety of tools, controls, and templates available from Microsoft, partners, and the
different community.
 Integrated Development Environment plan, execute, and monitor our entire testing effort.
 Write code accurately and efficiently without losing file context.

Tools available in IDE

 Code editor
I. Auto completion
II. Syntax check
III. bracket Matching
 Compiling
 Debugging
 Documentation
 Libraries
 automation tool

Sadigya Subedi (HND / First Semester) 42


Code editor
The development environment where the users can write the code is called the shell. The code
editor is a text edit area that allows developers to edit, write and save the document of code. It
has different types of features that assist with the writing and editing of the code. These features
includes :-

 Auto-complete: Auto-complete or Auto-completion is also known as code completion This is


a designed which helps to save the time of the programmer while writing the code. As we or
the programmers start to type the first part of a function, it suggests or completes the function
and any arguments or variables.

 Syntax checks. This feature of code editor recognizes the incorrect use of syntax and
highlights any errors.

 Bracket matching. This is used for languages that use pairs of brackets to mark out blocks of
code. It allows the code to be read and understood more quickly. If you forget to close a
bracket while writing, colored sections may help us to detect missing brackets.

Compiling
When running, the compiler firstly analyzes all the language statements written to execute the
code one by one and then, in one or successive stages it builds the output code by making sure that
the statements that refers to other statement is referred correctly in the final code to execute the
program to provide output to the user.

Debugging
Debugging is a program within the IDE which is used to detect the errors during the process of
compilation. If the debugging feature detects any kind of errors during the compilation, then it
will suggest what the type of error is detected and on which line is the error detected.

Documentation
Documentation feature explains the purpose and the function of the code, by considering the
modules and variables used, and its expected behavior also gathers these into a text file which can
be handled by other developers to understand why and how the code was created.

Libraries
Libraries provides function which are not included in the core part of the programming
paradigm. Library functions can be imported and used at the start of the program code.

Sadigya Subedi (HND / First Semester) 43


Automation tool
The automation tool is also known as build automation tool which helps to save time of the
programmer by automatically doing the certain processes by itself. These automatically doing
process includes testing and compiling. These tools are extremely useful when a program has
numerous of lines of code which has to get executed. This feature not only improves the quality
of the software but also minimizes bad software builds. This feature also helps in saving money
and time.

Net database connectivity (ADODB)


ADODB is a library where we can collect objects and methods that we can use to connect to
data. ADOdb means Microsoft's ActiveX Data objects which help to establish connection to
databases and other data sources. The ADO Connection Object is used to create an open
connection to a data source. Through this connection, we can access and manipulate a database.

Steps for connectivity between .Net and database


The following is the procedure on how to create a simple C sharp application that connects to
a remote MySQL database and runs an SQL query.

Critically evaluating source code of procedural programming application


Here is an Sample Scenario of adding two numbers.

Sadigya Subedi (HND / First Semester) 44


The output of the program is shown below.

Positive aspect of source code application

 It needs less memory as it reduced amount of overhead during runtime also data and
methods are stored in the same memory location.
 Coding is excellent, simple and flexible for simple program.
 It has got good level of control because without knowing the CPU details we coded and
got the output.
 It is fast and efficient.
 Easy to maintain as each procedure can be debugged separately.

Negative aspect of source code application

 It has got no security as data is exposed in the program.


 Here importance is given to the function rather than the data.
 Programmers also need to specialize because each language is suitable for a different
type of application and it is difficult to learn them all.

Critically evaluating source code of object oriented programming application


Here is an Sample Scenario of finding Area of the rectangle.

Sadigya Subedi (HND / First Semester) 45


The output of the result is shown below.

Positive aspect of source code application

 It is easy to maintain and modify the existing code as the new objects can be created with
small change made to existing one.
 The code can be reused through the feature provided called as inheritance.
 The principle of data hiding helps in maintain the security of the program.
 Polymorphism allows interaction between the objects without clearly stating which type
of data we are abstracting.

Negative aspect of source code application

 Object oriented program design is tricky as we can see in the above sample scenario.

Sadigya Subedi (HND / First Semester) 46


 Inspite of giving major focus on object the appropriate class and objects becomes hard to
find.
 It consumes more memory and disk space as size of the program is larger.
 As the coding is vast so it is time consuming.
 It is also hard to understand for the beginner programmer’s as it is vast.

Critically evaluating source code of Event Driven programming application


Here is an Sample Scenario of Assignment Management System.

Positive aspect of source code application

 Event driven programming is flexible as the programming code follows a logical order
from first to the end and the flow is determined by events which allows the programmer
to be flexible about the order in which they carry out the code.
 Development is easier as the functionality can be added through programming more
events
 It also has a better software design outcomes we can consider our example as it looks
attractive than that of C and C++.

Negative aspect of source code application

 In event driven programming the errors can be more difficult to spot.

Sadigya Subedi (HND / First Semester) 47


 It runs slower considering to other programming paradigm as programs are complex with
GUI
 The programs have too many forms which is confusing for the developers to code on.
 The code of event driven programming is complex and is hard to understand

Conclusion
From the above activities we have explained the principles, characteristics, features,
examples of Procedural, Object oriented and Event driven Programming and critically evaluated
the event driven, object oriented and procedural programming.

Coding Standard
Coding standard is simply a set of rules and guidelines for the formatting of source code. A
well developed software organization want their developers to maintain some well-defined and
standard style of coding which is known as coding standards.

Advantage of coding standard

 Implementing the coding standards reduces the risk of project failures because software
becomes vulnerable to attacks if it is inconsistent, contains bugs and errors in logic which
is due to poor coding practice.

 A clear coding in the program gives the programmer an opportunity to reuse the code
whenever and wherever required which can reduce the time in coding along with the
efforts being made in the development of the program.

Sadigya Subedi (HND / First Semester) 48


 It becomes easy to allocate/find and correct the bugs in the software after the execution
and error is displayed if the source code is written in a consistent manner

 If coding standard is followed in the absent of the developer in the company/office any
other developer can understand the code and hence, can modify it at any time.

 If coding standard is followed worked can be divided in team and development of


application can be done in given due of time

PROCESSES INVOLVED IN DEBUGGING


 1) We have to find the problem.
 2) After finding the problem we have to described the errors in the problem then we have
to try to get as much input from the user to get the exact reason.
 3) We then have to capture the program screenshot whenever the bug appears.
 4) We then examine in detail about the screenshot took and based on that screenshot we
try to find the cause of the bug.
 5) We then have to remove the existing bug and also has to check that if any kinds of
new bug does have arisen in the program.

Coding standard

 Indentation
 Commenting code
o Single line comment
o Multi line comment
 Variable declaration
 Naming convention for Package Class
 Camel case
 Pascal case

Indentation
In function definitions indentation denotes the code which is a part of the function. Indentation
makes programs easier to read and understand.

Commenting code
Commenting of code is done in order to know at the future why the code was written in such
type. For example to follow camel case we write a comment camel case is followed in order to
know in future during the edit of the code that instead if pascal case we have to follow camel

Sadigya Subedi (HND / First Semester) 49


case to get bug free output.
There are two types of comment Single line comment and Multi line comment.
Single line comment
In single line comment the commenting is done for a single code.

This is an example of single line comment.

Multi line comment


In multi line comment the commenting is done for a multi code at once.

This is an example of multi line comment.

Variable declaration
Variable declaration is a process of declaring the variable while coding in the programming
language. There are different type of variable declaration like int, string, char, etc.

Naming convention for Package Class


This naming class helps to declare whether the objects are private or public. Here is an example
of convection for package class

Sadigya Subedi (HND / First Semester) 50


Camel Case
Camel case is the word which have first letter small and subsequent word part is capital.
Example-sadigya Subedi

Pascal Case
Pascal Case is the word which have the first letter capital and subsequent word is also capital.
Example-Sadigya Subedi

This is an example of pascal case.

Debugging process to help develop more secure applications


The Visual Studio has the Visual Studio remote debugging monitor in which security
recommendations screen pops up for configuring so that users wouldn’t have any advantage
when they remove any errors on our computer.

We can also use firewall to keep any potential threats localized and also debug locally if we have
to debug an unfamiliar process in the visual studio remote debugging monitor. We should also
not use windows authentication mode infront of the unknown user because they may connect to
Microsoft® Visual Studio® 2005 from Microsoft Corporation also known as msvsmon.exe
which is dangerous because the unknown user may grant permission to access all the feature on
our computer.

Sadigya Subedi (HND / First Semester) 51


We should also be aware to not debug the webservices which are on internet and are unsecured.
We should also not download any project from the internet source and load into visual studio
because it is also harmful even without debugging.

Critically evaluation of why coding standard is necessary in a team and individual

Pros of coding standard For developer

 The user can know why the code was written at any time.
 If a source code is consistent bugs can be easily maintained without getting confused.

For team

 There will be consistency in the naming of the variable throughout the entire project.
 The code will be understand by one another even after exchanging the given work at
any time of the project.
 Coding is also good starting point for new team members or external developers who
support our team.
 All the member in the team will name the function according to what the other
member of the team does.

Cons of coding standard

 Too much explanation will make your code look clumsy.

Sadigya Subedi (HND / First Semester) 52


Sadigya Subedi (HND / First Semester) 53
Sadigya Subedi (HND / First Semester) 54
Sadigya Subedi (HND / First Semester) 55

You might also like