2nd Programming Assignment
2nd Programming Assignment
Table of Contents
Learning outcome 1: Define basic algorithms to carry out an operation and outline the process of
programming an application....................................................................................................................2
P1: Algorithm, Explanation, Problem and Example:............................................................................2
M1: Application Programming process.................................................................................................2
D1: Implementation of an algorithm.....................................................................................................2
Learning outcome 2: Characteristics of procedural, object-orientated and event-driven
programming.............................................................................................................................................3
P2: Explanation, Features, and Relationships:.....................................................................................3
M2: Compare, Contrast used with a source code of an application:.....................................................4
D2: Critically Evaluation, code structure and characteristics...............................................................9
Learning outcome 3: Using an IDE, write fundamental algorithms in code.......................................11
P3: Write a program that implements an algorithm using an IDE:....................................................11
M3: Use of an IDE for development of applications:..............................................................................15
D3: Use the IDE to control the program's development process:............................................................16
Learning outcome 4: Importance of a coding standard and debugging process................................16
P4: Debugging procedure and IDE debugging facilities:....................................................................16
M4: Evaluate, help develop more secure debugging, robust applications:.........................................17
D4: Evaluate why a coding standard is necessary:..............................................................................18
P5: Outline the coding standard you have used in your code:............................................................18
1
Learning outcome 1: Define basic algorithms to carry out an operation and
outline the process of programming an application.
P1: Algorithm, Explanation, Problem and Example:
An algorithm is a procedure that gives a series of instructions that must be followed in a certain
sequence in order to achieve the intended outcome. Algorithms may be implemented in more
than one computer language since they are often invented independently of the underlying
languages.
Characteristics:
Input
Output
Finiteness
Validity
2
4. Start with a simple example
5. Validate with a trusted implementation
6. Write up your process
Write a Program
The aim of programming is to describe the design to your computer. That is, instructing
students on how to solve the design.
A programmer is typically written in three stages:
Coding
Compiling
Debugging
// function declaration
int main ()
int a = 10;
int b = 20;
int res;
std::cout << a << "+" << b << "=" << res << std::endl;
return 0;
int result;
return result;
OOP
// C++ program to implement the ATM
// Management System
#include <iostream>
#include <stdlib.h>
#include <string.h>
4
using namespace std;
class Bank {
// Public variables
public:
// Function to set the person's data
void setvalue()
{
cout << "Enter name\n";
cin.ignore();
5
cin >> tot;
}
// Function to display the required data
void showdata()
{
cout << "Name:" << name << endl;
cout << "Account No:" << accnumber << endl;
cout << "Account type:" << type << endl;
cout << "Balance:" << tot << endl;
}
// Function to deposit the amount in ATM
void deposit()
{
cout << "\nEnter amount to be Deposited\n";
cin >> amount;
}
// Function to show the balance amount
void showbal()
{
tot = tot + amount;
cout << "\nTotal balance is: " << tot;
}
// Function to withdraw the amount in ATM
void withdrawl()
{
int a, avai_balance;
cout << "Enter amount to withdraw\n";
6
cin >> a;
avai_balance = tot - a;
cout << "Available Balance is" << avai_balance;
}
};
// Driver Code
int main()
{
// Object of class
Bank b;
int choice;
7
cout << "\t5. Withdraw Money\n";
cout << "\t6. Cancel\n";
cin >> choice;
8
}
}
call event-handler for event_nn with event parameters else handle unrecognized event // ignore or raise
exception
end loop
Object-oriented programming revolves around the concepts of objects and classes. In Java, the
classes are referred as templates for the objects while the objects are instances of a class so, the
objects can inherit all the characteristics, variables, and functions of the class.
Procedural programming gets its name due to the concept of procedural calls. Like other
programming paradigms, it has its own advantages and disadvantages. So, take note of them and
compare them with your requirements to know whether the popular programming paradigm
works out for you or not.
fact = fact * i;
cout « "Factorial of " << num « " is: " << fact << endl;
return 0;
class GFG {
System.out.println("GfG!");
class Signup { int userid; String name; String emailid; char sex; long mob;
public void create(int userid, String name, String emailid, char sex, long mob){
this.emailid = "radha.89@gmail.com";
this.sex = 'F';
10
this.mob = 900558981;
Event-driven paradigms
o Service oriented
o Time driven
import asyncio
1p = asyncio.get_event_loop()
1p.call_soon(hello_world, 1p)
1p.run_forever() 1p.close()
#include<vector>
#include<stdio.h>
#include<cstring>
#include<fstream>
#include<algorithm>
class course {
char name[80],branch[50];
void input() {
cin>>reg; fflush(stdin);
11
cout<<"\t\tDisplay Records";
cout«"\n";
system("PAUSE");
system("CLS");
}; vector <course>v;
void get_file()
course x;
2 -s 2 n .
fstream f;
f.open("College.txt",ios::out);
for(int i=0;i<v.size();i++) {
(.close();
for(i=0;i<v.size();
} return ta;
12
1++) if(strcmp(v[i].name,name)==0)
Figure 1
Figure 2
13
Figure 3
Figure 4
Figure 5
14
Figure 6
Figure 7
15
elax (n.d.). [online] Available at: https://www.veracode.com/security/integrated-
development-environment [Accessed 21 Jul. 2022].
Debugging facilities
The ability to run or halt the target program at specific points, display the contents of memory,
CPU registers, or storage devices (such as disc drives), and modify memory or register contents
to enter selected test data that could be the cause of faulty program execution are all common
debugging features. If a part of code produces different results than expected, attempt to make
that section of code operate in isolation. elax (n.d.). [online] Available at:
http://www.qnx.com/developers/docs/6.5.0/index.jsp?topic=
16
%2Fcom.qnx.doc.ide.userguide%2Ftopic%2Fdebug_Base_.html [Accessed 21 Jul.
2022].
Figure 8
Figure 9
17
perhaps as research towards producing better tools to be used in the software design and
engineering process. However, security and resilience are qualities that must be included in both
the design and execution of software.
18
It may seem to be something you'd say to a child, but I'd love to hear these comments when I do
an interview. elax (n.d.). [online] Available at:
https://www.freecodecamp.org/news/object-oriented-programming-concepts-
21bb035f7260/#:~:text=The%20four%20principles%20of%20object,abstraction%2C
%20inheritance%2C%20and%20polymorphism. [Accessed 21 Jul. 2022].
19