0% found this document useful (0 votes)
109 views6 pages

CSC101 Module 2

This document provides an introduction to the elements of a computer programming module. It discusses the key topics of syntax, semantics, and flowcharting. The module contains two lessons - the first on syntax and semantics, explaining that syntax refers to the structure of code while semantics refers to the meaning and desired output. The second lesson will cover flowcharting to diagram a process. Learners are instructed to carefully read the material, complete exercises, and contact the instructor if they have any questions.

Uploaded by

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

CSC101 Module 2

This document provides an introduction to the elements of a computer programming module. It discusses the key topics of syntax, semantics, and flowcharting. The module contains two lessons - the first on syntax and semantics, explaining that syntax refers to the structure of code while semantics refers to the meaning and desired output. The second lesson will cover flowcharting to diagram a process. Learners are instructed to carefully read the material, complete exercises, and contact the instructor if they have any questions.

Uploaded by

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

MODULE 2 – INTRODUCTION TO ELEMENTS OF A PROGRAM 3. You must answer the Learning Activities/Exercises (LAEs).

must answer the Learning Activities/Exercises (LAEs). The LAEs are designed to help
you acquire the SLOs.
4. Feel free to chat, call, text (09069352363) or send an email ([email protected]) message
I. INTRODUCTION to me if you have questions, reactions, or reflections about the contents or activities in the module.
Any system including a program has its elements. The only way to truly understand the entirety 5. The Practice Task/Assessment and the Assignment shall be checked by me.
of something is by carefully studying what comprises it. In this module, we will be talking about syntax
and its semantics along with flowcharting of a program. V. LESSON 1: Syntax and Semantics

II. COURSE LEARNING OUTCOMES A. Specific Learning Outcomes


1. Participate in the generation of new knowledge of fundamental principle of programming in At the end of the lesson you will be able to:
development projects. 1. differentiate syntax from semantics
2. Respond to computer programming activities with substantial degree of independence as an 2. identify proper constructs of C++ syntax with the right semantics
individual or a team. 3. practice coding with proper syntax
3. Defend a programming project implemented as a solution to a given problem in Computer
Science. B. Motivation/Prompting Question (s)
4. Articulate the latest developments of algorithms that maybe implemented as a solution to a You have learned English for almost two (2) decades of your life. Have you wondered how you
given problem. learned to speak English despite the fact that your mother tongue is different? In programming, do you
5. Embody different roles within a team in testing, and debugging a program. think you can understand the arcane language of C++? Are you willing to learn its secrets in order to
6. Apply knowledge of science on fundamental programming components appropriate to become a programmer someday? Together, we shall slowly learn its mysteries.
Computer Science.
7. Apply knowledge of basic computing appropriate to Computer Science. C. Discussion
8. Apply knowledge of integrated development environment through algorithms that maybe C.1. Syntax
implemented as a solution to a given problem. According to Brewer, R. (2020), syntax is the study of sentence structure and the rules
III. CONTENTS OF THE MODULE of grammar. While people can do what they want with language (and many often do), syntax
Lesson 1: Syntax and semantics helps common users of a language understand how to organize words so that they make the
Lesson 2: Flowcharting most sense. In our case, words are equivalent to identifiers, keywords, expressions, and
IV. HOW TO USE THIS MODULE strings.
This module will benefit you much through following all points carefully. The necessary key Example in programming:
points for you to familiarize are summarized as follows: cout<<x+y<<” the is answer”;
1. This module contains one (1) lesson. The lesson is explained substantively. Read the int x,y,z=0;
explanations thoroughly so that you could understand the lesson fully. cin>>a;cout<<a;
2. On the first page of the lesson, you will find the specific learning outcomes (SLOs) of each These are all syntactically correct. When a program compiles successfully, it can be
lesson. SLOs are knowledge and skills you are expected to acquire at the end of the lesson. Read them assumed that the codes are all syntactically correct. However, we can never assure that it will
heartily. not cause run-time error. We can say that a syntax error can cause semantic errors aswell.

Prepared by: Mr. Ted Elrico R. Tamparong


C.2. Semantics Code Syntax Sematics
Semantics, on the other hand, is the study of the meaning of sentences as stated by int xy,z;
Brewer, R. (2020). In our case, sentences are equivalent to code statements. cout << ( xy =3 ) << “The 1st number is: “ << endl;
From this, we can infer that semantics refers to the desired output of the program. This cout << “z is: ” << z <<endl;
would mean that the user of the program can easily comprehend what is happening in the char a = ‘a’;
program. string A = “A”;
Example in programming cout << “small a is: “ << a <<endl;
int x,y; cout << “big A is: “ << A << endl;
cout<<”Enter a first number: “; cin>>x;
cout<<”Enter second number: “; cin>>y;
cout<<”Their sum is: “<<x+y; E. Teacher Intervention
The case is, “Take two numbers as input from the user. Show the sum of the For clarifications, feel free to chat, call, text (09069352363) or send an email
two numbers to the user.”. This is a sample syntactically correct program. ([email protected]) message to me if you have questions, reactions, or reflections about the
Although it is not explicitly stated in the case what you should output, but making the contents or activities in the lesson.
user comprehend what is happening is part of semantics.
C.3. Syntax vs Semantics VI. LESSON 2: Flowcharting
Syntax is the structure or form of expressions, statements, and program units but
Semantics is the meaning of those expressions, statements, and program units. Semantics A. Specific Learning Outcomes
follow directly from syntax. Syntax refers to the structure/form of the code that a specific At the end of the lesson you will be able to:
programming language specifies but Semantics deal with the meaning assigned to the symbols, 1. picture out a whole process with the use of a flowchart.
characters and words. (Ebo, 2015). 2. connect the meaning of flowchart to program algorithm.
In summary, syntax is the concept that concerns itself only whether or not the sentence 3. make a sample flowchart of a simple process.
is valid for the grammar of the language. Semantics is about whether or not the sentence has a
valid meaning. (haccks, 2014). B. Motivation/Prompting Question (s)
Have you tried entering an establishment (government or private)? Have you seen figures that
D. Learning Activities/Exercises describes a process? Do you know how to interpret these things properly? Did you know that these figures
Identify whether the code codes are syntactically correct or semantically correct. Write true if it are also used in programming? Do you know how to describe a program using them? Let us bring your
is, and false if it is not true. confusion into light.
Code Syntax Sematics
float x = 9.2;
int x = 3;
string ans = “Answer: “;
cout << ans << x << endl;
bool a = true;
int b = false;
cout >> a+b >> “ = ” >> “1”;
Prepared by: Mr. Ted Elrico R. Tamparong
C. Discussion
C.1 Flowchart and Algorithm
C.1.a Flowchart C.2 Flowchart Symbols Cheat Sheet
The first design of flowchart goes back to 1945 which was designed by John
Von Neumann. Unlike an algorithm, Flowchart uses different symbols to design a
solution to a problem. It is another commonly used programming tool. By looking at a
Flowchart one can understand the operations and sequence of operations performed
in a system. Flowchart is often considered as a blueprint of a design used for solving
a specific problem. Flowchart is diagrammatic /Graphical representation of sequence
of steps to solve a problem (Walai, n.d.).
According to Walai (n.d.) the advantages of a flowchart are:
• Flowchart is an excellent way of communicating the logic of a program.
• Easy and efficient to analyze problem using flowchart.
• During program development cycle, the flowchart plays the role of a
blueprint, which makes program development process easier.
• After successful development of a program, it needs continuous timely
maintenance during the course of its operation. The flowchart makes
program or system maintenance easier.
• It is easy to convert the flowchart into any programming language code.

C.1.b Algorithm
The word “algorithm” relates to the name of the mathematician Al-khowarizmi,
which means a procedure or a technique. Software Engineer commonly uses an
algorithm for planning and solving the problems. An algorithm is a sequence of steps
to solve a particular problem or algorithm is an ordered set of unambiguous steps that
produces a result and terminates in a finite time.
According to Walai (n.d.) the advantages of an algorithm are:
• It is a step-wise representation of a solution to a given problem, which makes
it easy to understand.
• An algorithm uses a definite procedure.
• It is not dependent on any programming language, so it is easy to understand
for anyone even without programming knowledge.
• Every step in an algorithm has its own logical sequence so it is easy to
debug.

Prepared by: Mr. Ted Elrico R. Tamparong


Source: https://www.breezetree.com/downloads/flow-chart-symbols.pdf D. Learning Activities/Exercises
C.3 Sample Flowchart of a Process Construct a flowchart of your enrollment process (the way you enrolled in NORSU).
Purchasing Mobile Load You NORSU

You Vendor

Start Vendor states


cost of the load

Identify how Notify vendor


much to load

Prepare
amount and Notify you
state mobile
number Pay amount
Vendor keys in
mobile number
and prepares
change if any.

Awaiting
Receive confirmation
mobile load
and change

End

Prepared by: Mr. Ted Elrico R. Tamparong


E. Teacher Intervention
For clarifications, feel free to chat, call, text (09069352363) or send an email
([email protected]) message to me if you have questions, reactions, or reflections about the
contents or activities in the lesson.

VII. REFERENCES
1. Brewer, R., 2020. Semantics vs. Syntax vs. Pragmatics (Grammar Rules). Available at
https://www.writersdigest.com/write-better-fiction/semantics-vs-syntax-vs-pragmatics-
grammar-rules
2. Ebo, K. @stackoverflow.com, 2015. What is the difference between syntax and semantics in
programming languages? Available at https://stackoverflow.com/questions/17930267/what-is-
the-difference-between-syntax-and-semantics-in-programming-
languages#:~:text=Syntax%20refers%20to%20the%20structure%2Fform%20of%20the%20co
de%20that,the%20symbols%2C%20characters%20and%20words.&text=While%20semantics
%2C%20It%20concern%20to,concept%20of%20sentence%20or%20statements.
3. [email protected], 2014. What is the difference between syntax and semantics in
programming languages? Available at https://stackoverflow.com/questions/17930267/what-is-
the-difference-between-syntax-and-semantics-in-programming-
languages#:~:text=Syntax%20refers%20to%20the%20structure%2Fform%20of%20the%20co
de%20that,the%20symbols%2C%20characters%20and%20words.&text=While%20semantics
%2C%20It%20concern%20to,concept%20of%20sentence%20or%20statements
4. Walai, R., (n.d.), ALGORITHM AND FLOWCHART MANUAL for STUDENTS. Available at
http://www.yspuniversity.ac.in/cic/algorithm-manual.pdf

Prepared by: Mr. Ted Elrico R. Tamparong


Prepared by: Mr. Ted Elrico R. Tamparong

You might also like