Programmingpart 1
Programmingpart 1
PROGRAMMING
#include <iostream.h>
▪ cout object
▪ cin object
Identifier
Define variable
Data type
Integer
Floating point
Char
Boolean
Literal
Variable Definition
Variable Assignment
Variable Initialization
Arithmetic operation
Comment
Mathematical Expressions Order of Operations
Algebraic Expressions
Constants
Program output
Character Name Meaning
{ } Open/close brace Encloses a group of statements
Programming is fun!
This produces one line of output:
Programming is fun!
You can use the endl manipulator to start a new line of
output. This will produce two lines of output:
Programming is
fun!
You can also use the \n escape sequence to start a new
line of output. This will produce two lines of output:
TIP: Notice that the \n is
INSIDE the string.
Programming is
fun!
cout<<"Saya belajar di UPSI"<<endl<<"Saya suka UPSI"<<endl;
cout<<"Saya akan belajar rajin-rajin";
cout<<"Saya belajar di UPSI\nSaya suka UPSI\nSaya akan belajar rajin-rajin Saya pelajar multimedia";
My name is Shakirah.
I’m studying at UPSI.
I’m doing degree in Software Engineering.
cout<<“******\n******\n********\n”<<endl<<endl<<“##########”;
******
******
********
##########
An identifier is a programmer-
defined name for some part of a
program: variables, functions, etc.
A variable name should represent the
purpose of the variable. For example:
itemsOrdered
sum
Sum
Example
int number;
EXAMPLE
// This program has a variable
#include<iostream.h>
number = 20;
cout<<"The value in number is "; The value in number is 20
cout<<number;
}
EXAMPLE
// This program has a variable
#include<iostream.h>
number = 10;
cout<<"The value in number is "; The value in number is number
cout<<"number";
}
Notes:
Output