Save
CSC 2.3 S2
Save
Share
Learn
Content
Leaderboard
Learn
Created by
Kipasss
Visit profile
Cards (41)
Basic
Data
Type and
Declaration
Integer
Floating
point
Double
Character
String
Boolean
Data type:
int
Size:
4
bytes
Description: Stores whole
numbers
,
without
decimals
Data type:
float
Size: 4 bytes
Stores
fractional
numbers, containing
7
decimal digits
Data type:
double
Size: 8 bytes
Stores fractional
numbers
, containing
15
decimal digits
Data type:
Boolean
Size:
1
byte
Stores
true
or
false
values
Data type:
char
Size:
1
byte
Stores a single character/
letter
/
number
#
include
<iostream> using namespace std;
int
main () { int myNum = 1000;
cout << myNum; return 0; }
#include <
iostream
> using namespace std; int
main
() { float myNum = 5.75; cout << myNum; return 0; }
#include <iostream> using namespace std; int main
(
)
{ double myNum = 19.99; cout << myNum;
return
0; }
#include <iostream>
using
namespace std; int main () { char myGrade = 'B'; cout << myGrade; return 0;
}
STRING
#include <iostream> #include <
string
> using namespace std;
int main() {
string greeting = "Hello";
cout
<<
greeting
;
return 0; }
#include <iostream> using namespace std; int main() {
bool
isCodingFun =
true
; bool isFishTasty =
false
;
cout << isCodingFun << "
\n
";
cout << isFishTasty;
return 0; }
OUTPUT:
1
0
Punctuation
symbols:
,
.
:
;
?
!
Parentheses
: ()
Braces:
{
}
Brackets
: []
Quotation
marks: " '
Variable:
Data type
+
VariableName
Example: int x, y;
float radius;
char gred;
IDENTIFIER
:
Combination
of letters (both
uppercase
and
lowercase
),
digits
and the
underscore
()
IDENTIFIER: underscore
Data-1 :
invalid
M_6 :
valid
IDENTIFIER
: The first character must be a
letter
or an
underscore
the rest of the name can be
letter
,
digit
or an
underscore
IDENTIFIER
: first letter
_City or City:
valid
17numbers:
invalid
IDENTIFIER:
Blank space
is not allowed
IDENTIFIER
: no blank space
Student_age :
valid
Student age :
invalid
KEYWORD :
Must
be
typed
fully in
lower
case
Keyword
example: while, return, float, char, dll
ESCAPE SEQUENCE
: The backslash (\) is called
escape character
\n
: new line
\t
: horizontal tab
\" : double quote
\'
: single quote
\\ :
Backslash
to print a backslash character
\
?
: Question mark
Constant
Char
String
Int
Float
Double
INTEGER CONSTANT • Positive or negative whole numbers with no
fractional
part
7550 :
valid
3.44 :
invalid
INTEGER CONSTANT
Consists of an optional plus (
+
) or a minus (
-
) sign
-15 :
valid
0179 :
invalid
INTEGER CONSTANT Has no
comma
or other special character
+250 :
valid
1,899 :
invalid
INTEGER CONSTANT
const int x = 7;
CHARACTER CONSTANT
A
single
character enclosed in single quotation marks
CHARACTER
CONSTANT
const char category = 'A';
FLOATING POINT CONSTANT Positive or negative
decimal
numbers
with an integer part, a decimal point and a fractional part
FLOATING
POINT
CONSTANT
const float gov_tax 2.5;
See all 41 cards