













Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!














1
2
4
A C++ program is a collection of
functions
Function: set of statements whose
objective is to accomplish something
Preceding program consists of
function main
◦ Heading: int main()
#include
use cout and endl
5
// a program that add two numbers
#include
using namespace std;
// program to add numbers
int main(){
int firstNumber ;
int secodNumber ;
int sum;
firstNumber = 5;
secondNumber = 10;
sum = firstNumber +
secondNumber;
cout << sum ;
system (“pause”);
}
Single line
// This is a C++ program. It displays three lines
// of text, including the sum of two numbers.
Multiple line
/*
You can include comments that can
occupy several lines.
*/
Identifiers are names of things in a program. Things
in programs are variables, constants, and functions
Identifiers in C++ are case sensitive
◦ NUMBER is not the same as number
Rules to name identifiers are as follow:
◦ Named identifiers cannot be the same as reserved word
◦ Identifier consists of letters, digits and underscores character
(_)
◦ Identifier cannot begin with a digit
◦ Identifier cannot have any symbols except underscore
◦ Identifiers cannot have
first
conversion
payRate
Integral: integers
Floating-point: decimal numbers
Enumeration type: user-defined data
type
Two values: true and false
Manipulate logical (Boolean)
expressions
◦ 'A', 'a', '0', '*', '+', '$', '&'
Data type Values Storage (in bytes)
int -2147483648 to 2147483647 4
bool true and false 1
char -128 to 127 1
float -3.4E+38 to 3.4E+38 4
double -1.7E+308 to 1.7E+308 8
Enclosed in double quotation marks