P1 (Programming)
P1 (Programming)
P1 (Programming)
are comprised of hardware (equipment) and software (instructions that make the equipment operate).
A computer needs a software for you to be able to run such applications and do it base on your purposes.
1. Memory
a collection of registers and storage devices that store the computer's state map.
Two types of memories:
Primary memory: temporary store files
-Random access memory: ex: phones
Secondary primary: permanently store files
-The hard disk
2. Central Processing Unit (CPU)
The "brains" of the computer, which does the work of changing the state map stored in memory.
3. Input/Output (I/O) Processor
manages and performs the work associated with reading information that is added to portions of the computer's state map.
4. Peripherals
a.devices that store ancillary software and data,
b. output devices such as printers and plotters,
c. input devices such as a mouse or scanner, as well as the keyboard or display device (e.g.,the monitor).
KEYWORD:
1. Microcode
low-level instructions that make the CPU run correctly.
2. Machine Code
slightly higher-level than microcode, these instructions are loaded directly into memory and comprise a stored, executable program.
3. I/O and Computational Libraries
Sets of procedures and instructions that the I/O processor and CPU use to input or output data, as well as compute various arithmetic, math,
and data handling operations.
4. Application Software
programs that users run to accomplish various home, business, and scientific tasks such as word processing, spreadsheets, drawing or
sketching, graphics, and games.
5. Operating System
interfaces application software (and hardware) with libraries and microcode in a convenient manner that is transparent to the user.
Example: windows 10 or 11
A program is a set of step-by-step instructions that directs the computer to do the tasks you want it to do and produce the results you want.
Programming is the process of writing an algorithm into a sequence of computer instructions. (process of writing programs)
A set of rules that provides a way of telling a computer what operations to perform is called a programming language
LESSON 2
The Internet and Number Systems
Internet
is a worldwide interconnection of thousands of different computers and networks. It allows users to efficiently share information, programs
and equipment and to communicate with each other.
All computers on the Internet communicate with one another using the Transmission Control Protocol/Internet Protocol (TCP/IP)
suite.
Uses of Internet
E-mail and other forms of communication
searching for jobs
instant messaging, video conferencing and social media
Online discussion groups and forums, dating, gaming, and shopping
Research, Reading electronic newspapers and magazines, and File transfer
As you know decimal, binary, octal and hexadecimal number systems are positional value number systems. To convert binary, octal and
hexadecimal to decimal number, we just need to add the product of each digit with its positional value. Here we are going to learn other
conversion among these number systems.
Hexa-decimal – (16)
LESSON 3
Most people access the Internet through Internet Service Providers (ISPs). In most locations, you can now access Internet with local telephone
lines.
Properly written C++ programs have a particular structure. The syntax must be correct, or the compiler will generate error messages and not produce
executable machine language.
Syntax-is the set of rules that define what the various combinations of symbols mean. This tells the computer how to read the code.
Compiler - is a special program that processes statements written in a particular programming language and turns them into machine language or
"code" that a computer's processor uses.
Listing 2.1 (simple.cpp) is one of the simplest C++ programs that does something
o The actual name of the file is irrelevant, but the name "simple" accurately describes the nature of this program.
o The extension .cpp is a common extension used for C++ source code.
o After compiling and executing (usually, the term used is "running")
#include <iostream>
void main () {
Functions contain statements that the compiler translates into executable machine language instructions.
The combination of backslash and the letter n represents the newline character. The "n" indicates that the printing on that line is complete, and any
subsequent printing should occur on the next line.
The closing curly brace ( } ) marks the end of the body of a function.
Both the open curly brace and close curly brace are required for every function definition
---------------
int main() (
o The type of data to pass on to other codes is always placed before the name of the function (main). In Listing 2.1, it returns nothing,
that is why void is placed before the main().
return 0;
o If the return value from Main is not used, returning void allows for slightly simpler code.
o The return value from Main is treated as the exit code for the process.
o If void is returned from Main, the exit code will be implicitly 0.
o Take note that 0 is also an integer.
o The using directive in Listing 2.2 (simple2.cpp) allows us to use a shorter name for the std::cout printing object. We can omit the std::
prefix and use the shorter name, cout. This directive is} optional, but if we omit it, we must use the longer name. The name std stands for
"standard," and the std prefix indicates that cout is part of a collection of names called the standard namespace.
o The std namespace holds names for all the standard C++ types and functions that must be available to all standards-conforming C++
development environments.
o name cout known to the compiler via its focused using directive
o provides a blanket using directive that makes all names in the std namespace available to the compiler.
o This approach offers some advantages for smaller programs
o This blanket using directive allows programmers to use shorter names as in the more focused using directives, and it also can use
fewer lines of code than the more focused using directives, especially when the program uses multiple elements from the std namespace.
o The statement in the main function in any of the three versions of our program uses the services of an object called std::cout.
o The std::cout object prints text on the computer's screen. The text of the message as it appears in the C++ source code is called a string, for
string of characters.
o Strings are enclosed within quotation marks(").
o The symbols << make up the insertion operator.
o You can think of the message to be printed as being "inserted into the cout object. The cout object represents the output stream; that is, text
that the program prints to the console window. The end of the message contains the symbol sequence in. This is known as a character
escape sequence. This newline character effectively causes the cursor to move down to the next line.
o The cout object, which is responsible for displaying text on the screen, receives the text to print terminated with the newline character to
move to the next line.
o we'll refer to this type of statement as a print statement, even though the word print does not appear anywhere in the statement.
o any statement in C++ must appear within a function definition. Our single print statement appears within the function named main
o we need the #include directive that brings the cout definition from <iostream> into our program. Depending on what we need our program
to do, we may need additional #include directives.
o The main function definition is required for an executable program, and we will fill its body with statements that make our program do as
we wish. Later, our programs will become more sophisticated, and we will need to augment this simple template
Multiple Statements
Each print statement "draws" a horizontal slice of the arrow. The six statements constitute the body of the main function. The body consists of all
the statements between the open curly brace The word delimit means to determine the boundaries or limits of something.
o The main function definition is required for an executable program, and we will fill its body with statements that make our program do as
we wish.
LESSON 4
Cin- >>, known as the Extraction Operator
Cout - <<
ARTIHMETIC EXPRESSION
Evaluation
ARTIHMETIC OPERATIORS:
+ ADDTION
- SUBTRACTION
* MULTIPLICATION
/ DIVISION
% MODULUS
UNARY OPERATOR
TRUNCATION
o Process of discarding the fractional part leaving the only whole no. part
o Simply removes any fractional part of the value