Lecture 3 Introduction To Programming
Lecture 3 Introduction To Programming
Lecture 3
PROGRAMMING 1
Post-task Exercises
a sequence of
designed to be a
instructions for a
compiled language
computer to execute the only one language programs built into
computers understand various programming
and that language applications that
consists of sets of translates high level
instructions made of languages to machine a set of tools are
allows the programmer ones and zeros level languages needed, known as the
to write efficient,
development toolchain,
structured, object-
whose core are a
oriented programs
compiler and its linker.
Integrated Development
simple to implement and
Environment (IDE)
are very useful to learn
generally integrates
the basics of a
several development
programming language
tools
Output
Operator
Engr. Jen Perez-Cabale Lecture 3 - INTRODUCTION TO PROGRAMMING 9
Example # 3 : THE HELLO WORLD PROGRAM AGAIN
Standard C comment
• Begins with the combination slash-star symbol /* and ends with the star-slash symbol */.
• Anything written between these symbol will be ignored by the compiler.
• /* This is a C style comment */
std
a program shall either qualify
each and every use of
elements of the, or introduce
visibility of its components.
• They can represent a • They can store a whole • They can represent real • The Boolean type,
single character, such number value, such values, such as 3.14 or known in C++ as bool,
as 'A' or '$'. as 7 or 1024. 0.01, with different can only represent one
levels of precision, of two states, true or
• The most basic type • They exist in a variety depending on which of false.
is char, which is a one- of sizes, and can either the three floating-point
byte character. be signed or unsigned, types is used.
depending on whether
• Other types are also they support negative
provided for wider values or not.
characters.
Example: int x = 0;
Example: int x (0); Example: int x{0};
•Known throughout
Located inside the entire program
Located inside and may be used by
the function
the main ( ) any piece of code
parameters
function
•Hold their values
during the entire
execution of the
program
•Declared outside
any function
Floating
Point Default type for
floating-point
literals is double.
Numerals • 3.14159
• 6.02e23
// 3.14159
// 6.02 x 10^23
• 1.6e-19 // 1.6 x 10^-19
• 3.0 // 3.0
x = 3; x = 3;
y = ++x; y = x++;
Conditional
Ternary 7==5 ? 4 : 3
Operator (?) 7==5+2 ? 4 : 35
>3 ? a : b
a>b ? a : b
Allows to convert a
value of a given
type to another
type
int i;
float f = 3.14;
i = (int) f;