Capital University of Science and Technology, Islamabad
Computer Programming
BS COMPUTE CS1123

Spring 2016
Algorithm and Programming
ALGORITHM
An algorithm is an ordered set of unambiguous, executable steps that
defines a terminating process
Polyas Problem Solving Steps
Understand the problem
Devise a plan for solving the problem
Carry out the plan
Evaluate t
Capital University of Science and Technology, Islamabad
Computer Programming
BS COMPUTE CS1123

Spring 2016
Introduction to Computer Programming
(CS1133)
INTRODUCTION
The term computer is derived from the compute, which
means to calculate or to calculate
Computer is an electronic device which is used to solve
different problems according to a set of instruct
Capital University of Science and Technology, Islamabad
Computer Programming
BS COMPUTE CS1123

Spring 2016
Control Structures
ARITHMETIC OPERATORS
Arithmetic Operators:
+ (addition),  (subtraction or negation), * (multiplication), / (division), % (mod,
(modulus or remainder)
Can use the operators +, , *, and / with both integral and floatingpoint
data typ
Capital University of Science and Technology, Islamabad
Computer Programming
BS COMPUTE CS1123

Spring 2016
Control Structures
CONTROL STRUCTURES
Control structures can be of three types
Sequence
Selection (by making a choice)
Repetition
SEQUENCE
Simple sequential programs
With such a program, the computer starts at the
beginning and follows the statement
Capital University of Science and Technology, Islamabad
Computer Programming
BS COMPUTE CS1123

Spring 2016
Simple Array Program
Task 1
#include<iostream>
using namespace std;
void main()
cfw_
int arr[5];
for (int i = 0; i < 5; i+)
cfw_
cout < "PLEASE ENTER THE NUMBER AT INDEX = "<i<endl;
cin > arr[i];
Task 2
#include<iostream>
using namespace std;
void main(