Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (4 votes)
12K views

Module 1 and 2 CE Computer Fundamentals Programming

This document provides an overview of a Computer Fundamentals Programming course for the 2nd semester of the 2018-2019 school year at Isabela State University. The course will cover fundamental concepts in computer programming using C#, including techniques, definitions, types of programming languages, generations of languages, and creating a simple system as a final project. The course is 2 credit units and meets for 6 hours per week.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
100% found this document useful (4 votes)
12K views

Module 1 and 2 CE Computer Fundamentals Programming

This document provides an overview of a Computer Fundamentals Programming course for the 2nd semester of the 2018-2019 school year at Isabela State University. The course will cover fundamental concepts in computer programming using C#, including techniques, definitions, types of programming languages, generations of languages, and creating a simple system as a final project. The course is 2 credit units and meets for 6 hours per week.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 77

1

Computer Fundamentals
Programming
2nd Semester, SY 2018-2019

IRMA T. PLATA, DIT


ISABELA STATE UNIVERSITY- Main Campus
College of Computing Studies, Information and Communications Technology
Echague, Isabela
About the Course
2

I. Course Title: Computer Fundamentals Programming


II. Course Description: This course provides fundamental
concepts in computer programming using C#. This
course also cover the techniques being applied in
programming. Computer hands-on will be conducted to
apply the different concepts learned.
III. Prerequisite: None
IV. Contact Hours: 6 hrs per week
V. Credit: 2 Units
Course Content/Outline
3

• Definition of Programming
• Purpose of Making Programs
• Programming Language
• Types of Programming Language
• Generations of Programming Language
• Examples of Programming Language
• Compiler
• Interpreter
• Choosing a programming Language
• How to make programs
Continuation…
4

• Flowchart
• Algorithm
• The C# programming Language
• What is C#?
• C# Operators
- (Mathematical, Assignment, Relational, Boolean)
• Looping
- (While, Do, For)
• Arrays
- (Single, Multi-dimensional Arrays)
• Textfiles
Course Requirements
5

• Quizzes
• Attendance
• Recitation
• Seatwork
• Written/Laboratory Midterm and Final
Examinations
• Laboratory Exercises
• Create a simple system using C# Programming
Language (Final Project)

Grading System:
Midterm & Final Exam – 50% Grade – 100%
Other components – 50%
6

Module 1: Introduction to
Computer Programming
What is a Program?
7

• An organized list of instructions that, when executed, causes


the computer to behave in a predetermined manner.

• A computer program, or just a program, is a sequence of


instructions, written to perform a specified task on a
computer.

• A program is like a recipe. It contains a list of ingredients


(called variables) and a list of directions (called statements)
that tell the computer what to do with the variables. The
variables can represent numeric data, text, or graphical
images.

• Without programs, computers are useless!


What is a Program?
8

• an app, application, software application or


software program is the most common software on
the computer that performs a special function or
task.
• For example, Microsoft Word is a word processor
program that allows users to create and write
documents and the browser you are using to view
this page is a program.

• Without programs, a computer would still work with


the operating system, but you would not be able to
do anything.
What is Programming?
9

It is an act of making programs


Without programs, computers are useless!

Programmer. A programmer, developer, dev, coder,


or software engineer is a person who creates
computer software. The term computer programmer
can refer to a specialist in one area of computers or
to a generalist who writes code for many kinds of
software.
What is software?
10

• Generic
• General
• does not necessarily always mean "program" or
"application" (e.g. a software "library" or "framework" is
not a "program" or "application", but are used to
facilitate the functional requirements of "programs" or
"applications").
Without programs, computers are useless!
Computer software, or simply
software, is a collection of data
or computer instructions that tell
the computer how to work. This
is in contrast to physical
hardware, from which the system
is built and actually performs the
work. Wikipedia
Why do programmers make computer
programs?
11

• To simplify task

• Provide accurate results

• Aide in facilitating day-to-day activities


a computers are useless!
LLL vs HLL
12

Low Level Language (LLL) – language that can convert


to machine code without a compiler or interpreter, and
the resulting code runs directly on the CPU/Processor.
(also known as the machine language or assembly
language – the zeros and ones (0,1))

High Level Language (HLL) – needs a compiler or


interpreter to convert the instruction into language that
could be understood by CPU/Processor.

a computers are useless!


What is CPU or Processor?
13

• CPU means central processing unit

• “Brain” of the computer

• Executes commands or instructions

Central processing unit


A central processing unit a computers
(CPU) is the are useless!
electronic circuitry within a computer that
carries out the instructions of a computer
program by performing the basic arithmetic,
logic, controlling, and input/output (I/O)
operations specified by the instructions.
Compiler
14

• It is a program that converts high level language to


low level language that could be understood by
the CPU (this process is called “Compiling”)

• Commonly compiles instruction known as the


“Code”
Interpreter
15

• It is a program that interprets (without


undergoing the process of compiling) high level
language to low level language that could be
understood by the CPU.

• Commonly compiles instruction known as the


“Script”
Types of Programming Language
16

• Web languages
• Software languages
• The different generations of languages
• Procedure oriented programming
• Object oriented programming
Types of Programming Language
17

Web Languages
• HTML
• XML
• JAVASCRIPT
• VBSCRIPT
• PHP
• ASP
• JAVA
Types of Programming Language
18

Software Languages
• C
• C++
• Visual Basic
• JAVA
• C#
Types of Programming Language
19

The different generations of languages


• 1st Generation Language (1GL)
• 2nd Generation Language (2GL)
• 3rd Generation Language (3GL)
• 4th Generation Language (4GL)
• 5th generation language (5GL)
The different generations of languages
20

First generation languages (abbreviated as 1GL)

Represent the very early, primitive computer


languages that consisted entirely of 1's and 0's -
the actual language that the computer
understands (machine language).
The different generations of languages
21

Second generation languages (2GL)

• Represent a step up from the first generation


languages. Allow for the use of symbolic
names instead of just numbers.
• Second generation languages are known as
assembly languages.
• Code written in an assembly language is
converted into machine language (1GL).
The different generations of languages
22

Third generation languages (3GL)

• With the languages introduced by the third


generation of computer programming, words
and commands (instead of just symbols and
numbers) were being used.
• These languages therefore, had syntax that
was much easier to understand.
• Third generation languages are known as
"high level languages" and include C, C++,
Java, and Javascript, among others
The different generations of languages
23

Fourth generation languages (4GL)


• The syntax used in 4GL is very close to
human language, an improvement from the
previous generation of languages.

• 4GL languages are typically used to access


databases and include SQL and ColdFusion,
among others.
The different generations of languages
24

Fifth generation languages (5GL)


• Fifth generation languages are currently
being used for Neural Networks.

• A Neural Network is a form of Artificial


Intelligence that attempts to imitate how the
human mind works.
Example Code of Visual Basic
25
Example Code of Python
26
Example Code of C#
27
28

End of Module 1
Note: prepare for a quiz next meeting
29
30

n
31

Computer Fundamentals
Programming
Module 2 - Designing and Creating a
Program

IRMA T. PLATA, DIT


ISABELA STATE UNIVERSITY- Main Campus
College of Computing Studies, Information and Communications Technology
Echague, Isabela
Algorithm
32

• A formula or set of steps for solving a particular problem.


• To be an algorithm, a set of rules must be unambiguous and
have a clear stopping point.
• Algorithms can be expressed in any language, from natural
languages like English

• We use algorithms every day. For example, a recipe for baking


a cake is an algorithm. Most programs, with the exception of
some artificial intelligence applications, consist of algorithms.

• Inventing elegant algorithms -- algorithms that are simple


and require the fewest steps possible -- is one of the principal
challenges in programming.
Examples of algorithm
33

• Cookbook
• Recipe Booklet
• Choreography

• In the same way, algorithms executed by computer can


combine millions of elementary steps, such as
additions, subtractions, multiplications and divisions
into complicated mathematical calculations.

• In the same way, algorithms executed by computer can


combine millions of elementary steps, such as
additions, subtractions, multiplications and divisions
into complicated mathematical calculations.
Examples of algorithm
34

Here is one algorithm for the usual process of saving a document


in a disk.

1. Find a new or unused disk.


2. Insert the disk in drive G.
3. From the word environment, select file menus then select
save as.
4. From the save as dialog box, select the directory where you
save the document.
5. Position the pointer inside the filename textbox then type the
filename of the document.
6. Then click the save button to formally save the document.
Problems (1,2,3,4,5)
35

1. Create an algorithm on how to kill a chicken.

2. Create an algorithm on how to prepare a cup of coffee.

3. Create an algorithm on how to cook pinakbet.

4. Create an algorithm on how to get the sum of two numbers.

5. Create an algorithm on how to get the average of the three


(3) numbers.
Flowchart
36

A flowchart is a graphical or symbolic representation of


a process. Each step in the process is represented by a
different symbol and contains a short description of the
process step.

The flow chart symbols are linked together with arrows


showing the process flow direction.
Basic Symbols
37

• A flowchart is a graphical or symbolic representation


of a process.

• Each step in the process is represented by a


different symbol and contains a short description of
the process step.

• The flow chart symbols are linked together with


arrows showing the process flow direction.
Basic Symbols
38
Basic Symbols
39
Basic Symbols
40
Basic Symbols
41
Basic Symbols
42
Basic Symbols
43
Basic Symbols
44
45

Example
of
Flowchart
Notations Used in Flowchart
46

Notation Meaning
: comparison
& logical and
Y yes
N no
EOF End of File
Relational Test Operators
47

Notation Meaning
> is greater than
< is less than
<= or =< is less than or equal to
>= or => is greater than or equal to
<> or >< is not equal to
= is equal to
Arithmetic Operators
48

Notations Meaning

+ Addition
- Subtraction
* Multiplication
/ Division
() Grouping
** or ^ Exponentiation
Precedence of the Operators
49

The computer follows this order of


priority

1. Grouping ()
2. Exponentiation
3. Multiplication or division
4. Addition or subtraction
When operators are all of equal priority, the
computer evaluate the expression from left
to right.
50
When operators are of different priorities, the
computer performs those operations with higher
priorities first
51
Operations enclosed in parentheses will take place
before other operations. Note (if there are multiple
parentheses, the innermost parenthesis will be
52

evaluated first).
Write clearly the computation desired
53

Example #2.3
2L / 3G
Answer?
( 2 * L ) / (3 * G )
Problem 6 and 7
54

6. Create a flowchart that would ask for a legal age to


access a particular porn site. If age is greater than or
equal to 18 then print “Yehey, you are allowed, happy
Viewing”, otherwise, print “Sorry, you can’t”.

7. Create a flowchart that would determine if


the grade of student is Passed or Failed. If grade
is greater than or equal to 75, print “Passed”,
else “Failed”.
Problem 8
55

Create a flowchart that would get the


average of student’s grade from 5
subjects (Math, Science, Social Sciences,
Biology, P.E) and determine whether the
average is passed or failed. If the average
is greater than 75, display “Passed”,
otherwise display “Failed”.
Loops and Counters
56

• Looping is used when it is desired to


make the same calculation on more than
one set of data. It consists of repeating a
program, or a section of a program, and
substituting new data for each repetition.

• A counter is set up in a program loop to


keep track of the number of times the
program segment is repeated.
Steps in Loop Control
57

1. Initialization – the value of a counter used is initially


set equal to zero (or one). This process is
always done outside the loop.
2. Test for Limit Conditions – before logic flow gets out
of the loop, a loop – terminating condition
must first be satisfied. The process of
testing is usually found either at the
beginning or at the end of a loop.

3. Incrementation – after each loop is executed, 1 is


added to the counter. Thus the counter
reflects the number of times the operation
has been performed. This process is always
done within the loop.
The algorithm for this particular requirement
could be listed as follows:
58

1. Initialize the counter (ctr) and accumulator (sum) to


zero.
2. Read in student’s name and score.
3. Print out the student’s name and score.
4. Accumulate the data value (score) into sum.
5. Test if the desired amount of data (40) has been
reached.
6. If the value of counter (ctr) is less than 40, repeat
steps 2 through 5. However, if the desired amount
of data has been reached (40), compute the average
score by dividing the sum by the value of counter.
7. Print out the average score.
Equivalent flowchart of the problem

59
Problem 9 and 10
60

9. Create a flowchart that would change the


initial value of the variable X which is 10 to
100 when the value of variable Y is 50.

10. Draw a flowchart that would convert the a


particular number to words. Numbers may be from
1 to 5. Example, if the value is 1, then it will display
the word “One”, “Two” for 2 and so on…
Problem 11
61

Find the amount to charge people of varying ages for a food


ticket. When the person is under 16, the charge is Php 7.00,
when the person is 65 or over, the charge is Php 5.00, all others
are charged Php 10.00. The conditions are the following:

Age Charge
<16 7
>=16 and <65 10
>=65 5
Problem 12 and 13
62

12. Calculate the commission rate for a salesperson given the


amount of sales. When the salesperson has sold less than of
equal to 2,000.00 worth of goods, the commission is 2%. When
the sales total is more than 2,000.00 and less than or equal
4,000.00 the commission is 4%. When the sales total is more
than 4,000.00 and less than or equal to 6,000.00, the
commission is 7%. When the salesperson sold more than
6,000.00, the commission is 10%.

13. Create a flowchart that would determine if a


particular number is an Odd number. When the
number is Odd, print “The Number is an Odd”.
Problem 14, 15
63

14. Create a flowchart that would determine if a


particular number is an Even number. When the
number is Even, print “The Number is an Even”.

15. Draw a flowchart that would count and display


all the even and odd numbers from 1 to 10.
64

End of Module 2
Note: prepare for a quiz next meeting; Submit all answer to Problems
provided, use the worksheet template provided.
65

Computer Fundamentals
Programming
Module 3 – The C# Programming
Language

IRMA T. PLATA, DIT


ISABELA STATE UNIVERSITY- Main Campus
College of Computing Studies, Information and Communications Technology
Echague, Isabela
Overview
66

• C# is a modern, general-purpose, object-oriented


programming language developed by Microsoft and
approved by Ecma and ISO.

• C# was developed by Anders Hejlsberg and his team


during the development of .Net Framework.

• C# is designed for Common Language Infrastructure


(CLI), which consists of the executable code and
runtime environment that allows use of various high-
level languages to be used on different computer
platforms and architectures.
Overview
67

The following reasons make C# a widely used professional


language:

• Modern, general-purpose programming language


• Object oriented.
• Component oriented.
• Easy to learn.
• Structured language.
• It produces efficient programs.
• It can be compiled on a variety of computer platforms.
• Part of .Net Framework.
C# Program Structure
68

• Namespace declaration
• A class
• Class methods
• Class attributes
• A Main method
• Statements & Expressions
• Comments
The C# Code
69

using System;

class HelloWorld
{
static void Main(string[]
args)
{
/* my first program in C#
*/
Console.WriteLine("Hello
World");
Console.ReadKey();
}
}
Line #1: using System;
70

The first line of the


program using
System; - the using
keyword is used to
include the System
namespace in the
program. A
program generally
has multiple using
statements.
Line #2: class HelloWorld
71

The next line has a class


declaration, the class
HelloWorld contains the
data and method
definitions that your
program uses. Classes
generally would contain
more than one method.
Methods define the
behavior of the class.
However, the
HelloWorld class has
only one method Main.
Line #4: static void Main(string[] args)

72

The next line


defines the Main
method, which is
the entry point
for all C#
programs. The
Main method
states what the
class will do when
executed
Line #6:/* my first program in C# */
73

The next line /*...*/


will be ignored by
the compiler and it
has been put to add
additional
comments in the
program.
Comments are used for explaining code.
Compilers ignore the comment entries. The
multiline comments in C# programs start
with /* and terminates with the characters
*/ as shown below:

/*
This program demonstrates
The basic syntax of C# programming
Language
*/

}//end of class hello world


Line #7: Console.WriteLine("Hello World");

74

WriteLine is a
method of the
Console class
defined in the
System
namespace. This
statement causes
the message
"Hello, World!" to
be displayed on
the screen.
Line #8: Console.ReadKey();

75

The last line


Console.ReadKey(); is
for the VS.NET Users.
This makes the
program wait for a key
press and it prevents
the screen from
running and closing
quickly when the
program is launched
from Visual Studio
.NET.
Note the following points
76

• C# is case sensitive.

• All statements and expression must end with


a semicolon (;).

• The program execution starts at the Main


method.
Identifiers
77

• Namespace declaration
• A class
• Class methods
• Class attributes
• A Main method
• Statements & Expressions
• Comments

You might also like