0% found this document useful (0 votes)
31 views11 pages

L01 Intro

This document provides an introduction to programming fundamentals and concepts. It discusses hardware components like the CPU, memory, and input/output devices. It then covers software topics such as programs, data, languages, compilers, and libraries. Example C++ code is shown to illustrate program layout and structure. Key points about syntax, semantics, and programming style are also outlined.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views11 pages

L01 Intro

This document provides an introduction to programming fundamentals and concepts. It discusses hardware components like the CPU, memory, and input/output devices. It then covers software topics such as programs, data, languages, compilers, and libraries. Example C++ code is shown to illustrate program layout and structure. Key points about syntax, semantics, and programming style are also outlined.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 11

Programming Fundamentals

Introduction
Hardware
 hardware - physical devices that make up computer equipment
 computer - PC/mainframes/workstations
 computer contains 5 main components
 CPU - follows the instructions and performs calculations specified by the
program
 input device - any device that allows outside world to communicate information
to the CPU
 output device - any device that allows CPU to communicate information to the
outside world
 main memory/primary memory/RAM - a list of addressable memory locations
that CPU can operate upon, not permanent
– bit - the least possible amount of information: 0 or 1
– byte - 8 bits
– memory location - single (indivisible) portion of memory that holds data
– address - number that identifies a memory location
 secondary memory – memory that is used for keeping a permanent record of
information – disk/data CD/flash drive

2
Hardware Diagram

3
CPU Accessing RAM

4
Software
 program – a sequence of instructions for computer to follow
 system – to be used by other programmers
– operating system – allocates computer resources, launches other programs and
ensures they work properly
 application – to be used by end-users
 software - collection of programs
 data - input to the program
 running/executing program - performing program instructions on given data
 languages
 natural - language used by humans
 high-level - language (close to natural) that is understood by humans, C++ is a high-
level language
 machine (low-level) - list of instructions in binary format that a computer understands
0101 0001 1100 0010
 code
 source (high-level language)
 object (machine language)
 executable code - can run on computer
 library – a collection of previously developed object code: input/output, math, etc.
 compiler – a system program that translates high-level language into low-level language
 linker - program that takes object code and produces executable code

5
Producing Executable Code
source code include files
(add1.cpp) (add1.h, iostream)
done by linker

link object
code with
check
object pre-compiled
file code routines from
add include unit for legal standard
(add1.o)
files syntax and libraries to
compile it into produce
an object standard executable
code code
libraries

done by compiler executable code


6
C++ Creation
Power vs. Understanding
 programming language properties
 power – ability to express variety of ideas, code tasks (ex: bigger toolkit); more
powerful language makes it easier to program
 understandability – ease of making sense of the code by proficient programmer
 in 1967, BCPL was developed as a language for writing operating systems and
compilers
 In 1970, the creators of UNIX operating system needed a high-level language that
provided enough (expressive) power and flexibility for their task. They developed B
on the basis of BCPL
 In 1972, an enhanced and improved version of the language called C was used to
code most of UNIX
 C is powerful yet,
 lower understandability: is easy to write code that is difficult to understand
 early 1980es, Bjarne Stroustrup developed an extension of C called C++
 absorbed best features of C, combines power of low-level language with
understandability of high-level language
 major addition is objects: C++ is object-oriented

7
C++ Popularity
 C/C++ are possibly the most popular programming languages in use
today
 most of operating systems (one of the largest and most complicated
pieces of software) is written in C or C++
 source code for Microsoft Windows 7 contains 40 million lines of

mostly C/C++
 source code for Linux Kernel (v.4.10.11) 18 million lines of

primarily C

8
C++ Program Layout
#include <iostream>
 include directive - tells compiler int main() {
where to find certain items about
the program statement 1;
main part (main function) - contain

instructions for computer, starts and
// comment
ends with curly brackets: {} statement 2;
 indiciates program start

 statement – single unit of execution ...


 each statement ends with semicolon ;
}
 program consists of a sequence of statements
 comment is a portion of line ignored by compiler - serves to make the code easier to understand by
humans
 line breaks and indentation is for humans - compiler ignores them. Make program easier to understand

9
First Program: helloWorld.cpp
include // displays a greeting
directive // Mikhail Nesterenko
// 8/25/2013 comments
#include <iostream>

using std::cout; using std::endl;


function
named int main() {
main() cout << "Hello, World!" << endl;
indicates
start of }
program

output
statement
Rules of Programming
 syntax - the principles of constructing (structuring) the program
 legal program construct complies with syntactic rules

 illegal violates

ex: every statement ends with a semicolon


 semantics – the meaning of programming constructs
ex: assignment statement gives a new value to a variable
 style – non-syntactic rules of program writing aimed at making program
easier to read and understand
ex: start the program with comments explaining its purpose

11

You might also like