You are on page 1of 27

Fundamentals of

Programming
MODULE 1
Story: https://nextshark.com/isabel-sieh-youngest-programmer-startup/
Module 1
Introduction to Programming
COURSE INTENDED
LEARNING OUTCOMES
CILO 1:
Discuss the importance of Programming and apply simple input
and output statements.
Lesson Objectives

Learn about programming tasks

Learn object-oriented programming concepts

Learn about the C# programming language

Learn how to write a C# program that produces output

Learn how to select identifiers to use within your programs



“Any fool can write code that a
computer can understand.
Good programmers write code
that humans can understand.”
― Martin Fowler
Program Defined
• A computer program is a set of instructions
that you write to tell a computer what to do.
Program?
A computer program is a set of instructions that you write
that tells a computer what to do

Programmer? Programming?
Programming is the action or process of writing
A programmer a person who writes
computer programs.
computer programs.
LEVELS OF PROGRAMMING
LANGUAGES

MACHINE HIGH
ASSEMBLY
LEVEL LEVEL
LANGUAGE
LANGUAGE LANGUAGE

consists of a set of instructions contains mnemonic commands consists of English-like statements that
that are in the binary form 0 or 1. such as mov, add, sub, etc. are easy to understand
Machine Language
• The only language that is ever actually
executed by a computer.
• Composed of instructions encoded as strings
of 0's and 1's.
• Never written and rarely read directly by
programmers
Assembly Language
• contains mnemonic commands such as mov,
add, sub, etc.
• 1-1: One assembly language instruction
corresponds to one machine language
instruction.
• The Assembler (a program) translates
assembly code into machine code.
High Level Language
• consists of English-like statements that are easy
to understand
• Assembly language is still tedious to work in so
most work done in HLL.
• Translated into machine language by a Compiler
(sometimes an intermediate language).
• One-to-many: One HLL statement translates into
several or several dozen of machine instructions.
Compiler

Source Code Object Code


(High Level Language) Compiler (Machine Language)

• The language processor that reads the complete source program written in high
level language as a whole in one go and translates it into an equivalent program
in machine language.
Assembler

Source Code Object Code


(Assembly Language) Assembler (Machine Language)

• The Assembler is used to translate the program written in Assembly language


into machine code.
Interpreter

Source Code Object Code


(High Level Language) Interpreter (Machine Language)

• The translation of single statement of source program into machine code is done
by language processor and executes it immediately before moving on to the next
line.
The C# Programming
Language
• C# was developed as an object-oriented and component-oriented
language
• It exists as part of the Visual Studio .NET package
• C# (like Java) is modeled after the C++ programming language
• Pointers are not used in C#
• C# does NOT require the use of object destructors, forward
declarations, or #include files
• It has the ability to pass by reference
• Multiple inheritance is not allowed in C#
Writing a C# Program that Produces Output

• “This is my first C# program” is a literal


string of characters
• The string appears in parenthesis
because it is a parameter or an
argument
• The WriteLine() method prints a line of
output on the screen
Writing a C# Program that Produces Output

• Out is an object that represents the


screen
• The Out object was created and
endowed with the method WriteLine()
• Not all objects have the WriteLine()
method
Writing a C# Program that Produces Output

• Console is a class
• Console defines the attributes of a
collection of similar “Console” objects
Writing a C# Program that Produces Output

• System is a namespace, which is a


scheme that provides a way to group
similar classes
• Namespaces are used to organize
classes
Compiling and Executing a Program from the
Command Line
• After creating source code, you must do the following before you can view the
program output:
• Compile the source code into intermediate language (IL)
• Use the C# just in time (JIT) compiler to translate the intermediate code into
executable statements
Compiling and Executing a Program from the
Command Line
• After compiling your source code (typing csc followed by the filename), you will
have three possible outcomes:
• You receive an operating system error message
• You receive one or more program language error messages
• You receive no error messages, indicating that the program has compiled
successfully
Compiling and Executing a Program from the
Command Line
• If you receive an operating system message it may mean that:
• You misspelled the command csc
• You misspelled the filename
• You forgot to include the extensions .cs with the filename
• You didn’t use the correct case
• You are not within the correct subdirectory or folder on your command line
• The C# compiler was not installed properly
• You need to set a path command
Compiling and Executing a Program from the
Command Line
• A syntax error occurs when you introduce typing errors into your program.
• The C# compiler issues warnings as wells as errors
• If a syntax error occurs, you must reopen the source code and make the
necessary corrections
• If you compile the program with no errors (using csc file.cs) you can run the
program from the command prompt by typing the name of the .exe file created
Compiling and Executing a Program from the
Command Line
Thanks!
Any questions?
References:
• https://www.tutorialsteacher.com/csharp/csharp-operators
• https://www.tutlane.com/tutorial/csharp/csharp-operators-
precedence-with-examples
• https://nextshark.com/isabel-sieh-youngest-programmer-
startup/

You might also like