Computer Fundamentals and Programming: Montaigne Garcia Molejon
Computer Fundamentals and Programming: Montaigne Garcia Molejon
Programming
Computer Programming
Computer programming (often shortened to
programming) 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.
Mechanical Age
(1450 1840 A.D.)
In this period, the information explosion and
the first general purpose computers was
exist and some computing devices which are
manually operated began to emerged and
more developers began to explore with their
own invention.
Charles Babbage
(1791 - 1871)
the invention of Charles
Charles Babbage
Babbages Difference
Engine
- this machine would be
able to compute tables of
numbers, such as logarithm
tables and was designed to
automate a standard procedure
for calculating roots of
polynomials. This first
difference engine would have
been composed of around
25,000 parts, weigh fifteen tons
(13,600 kg), and would have
been 8 ft (2.4 m) tall.
Babbages Analytical
Engine
- since the Difference Engine
was not fully completed that time,
Babbage designed a more
powerful mechanical computing
engine which is the Analytical
Engine. This engine marks the
transition from mechanised
arithmetic to fully fledged general
purpose computation.
Computer Language
A computer language is a set of rules and
conventions used to convey the information
to a computer.
Machine Language
The native tongue of a computer is the
Machine Language. Each Machine Language
instruction is a binary string of 0s and 1s that
specifies an operation and identifies the
memory cells involved in that operation.
Example:
Assembly Language
High-Level Language
High Level Language is a programming
language where an instruction resembles
everyday language. Instructions are given to
a computer by using a convenient letters,
symbols or English text rather than by using
1s and 0s code that the computer
understands.
Example is Visual Basicetc.
Example:
Visual Basic
Introduction to
C Language
What is C language:C
Its
It
History of C language:C
Dennis
It
BASICS OF PROGRAMMING
In order to run the program you need to go through several
stages. These are:
1)
2)
3)
Compiler
Compiler translates the whole source
program into machine language at once.
A large complex program that is responsible
for translating the source program into a form
that can be executed directly by the
computer.
NOTE:
If you are going to store the source file for future
alteration and development then you will need to
name the file in accordance with understood by
your compiler. Practically all C compilers expect
program source to be provided in files with
names ending in .c
C Data Types
Before a variable name (identifier) can be
used in a C program, it must be declared
explicitly, together with its corresponding data
type.
There are some restrictions in giving a name
to variables and constants.
Name can be composed of letters and
numbers, however the first character must be
a letter.
NOTE:
Keywords commands such as case, int, float,
if, do, for, etc.., cannot be used as variable or
constant names, because they are considered
as reserved words.
FORMAT
MEANING
EXAMPLE(S)
Int
%d or %i
A whole number
float
%f
A number with
decimal point
char
%c
A single letter,
symbol, or number
enclosed within
two single quotes
(B, r, 3 )
char
%s
A string in C is
considered as a
series if characters
double
%f
(12345678.123)
#include<> function
The line beginning with a hash sign # and
followed by include is called pre-pocessor.
It is a function which tells to the compiler to
include or to put Library file into C program.
Example Library file is the stdio.h
Structure:
#include <Library file>
Example:
#include<stdio.h>
#include<conio.h>
Semicolon ;
In a C program, the semicolon is a statement
terminator. That is, each individual statement
must be ended with a semicolon. It indicates
the end of one logical entity.
Structure:
main()
{
printf(Hello World!);
}
Output:
Hello World!
Basic Operators of C
Arithmetic Operators
Symbol
Meaning
Addition
Subraction
Multiplication
Division
Modulus(Remainder)
#include
main()
printf()
console.
getch()
Hello C Language
scanf()
scanf()
If else-if ladder Statement: The if else-if statement is used to execute one code from
multiple conditions.
Syntax:
if(condition1){
//codetobeexecutedifcondition1istrue
}elseif(condition2){
//codetobeexecutedifcondition2istrue
}
elseif(condition3){
//codetobeexecutedifcondition3istrue
}
...
else{
//codetobeexecutedifalltheconditionsarefalse
}
Syntax
Call by value in C language:In call by value, value being passed to the function is locally
stored by the function parameter in stack memory location.
If you change the value of function parameter, it is
changed for the current function only. It will not change
the value of variable inside the caller method such as
main().
Array in C: Array