C and C++ Programming Model PRT - 2
C and C++ Programming Model PRT - 2
Gerald L. Almodiel
Data Types
Types of Characters
Types of Integers
Floating-point Numbers
Sample Programs
Variables
Location in the memory where value or
data can be stored
Case-sensitive
Variable Declaration
We declare variables with its name
and data types before use
e.g.
int num1;
We can declare variables of same
type in one declaration
e.g.
int num1, num2, num3;
Identifiers
Is a sequence of one or more letters,
digits and underscore characters
Data Types
It is the name of the type of the value that we
stored in variables
3 Common Data Types
int – integer numbers
int num = 5;
char – characters
char x = ‘x’;
double – floating-point numbers
double num1 = 20.221;
Character Types
Integer Types
Floating-point Types
Boolean Types
#include <iostream>
using namespace std;
int main()
{
// variable declaration
int num1 = 1; // variable num1 with data type integer and value 1
char x = ‘x’; // variable x with data type char and value character x
double num2 = 25.5; // variable num2 with double data type and value 25.5
bool guess1 = true;
bool guess2 = false;
ANY QUESTIONS ?
~ FIN