Programming languages

source code --> intermediate language --> object code (+linker libraries) --> machine code (executable file)

In C++:
    Primitive Data Structures
  • Boolean : bool
  • Character : char, unsigned char, signed char
  • Integer: int, unsigned int, signed int, short int, unsigned short int, signed short int, long int, signed long int, unsigned long int
  • Floating point: float
  • Double floating point: double, long double
  • Valueless: void
  • Wide character: wchar_t
  • To know the size in bytes:
    • cout << "Size of char : " << sizeof(Data_type) << endl; return 0;
  • To create a new name for an existing type:
    • typedef Existing_type newname;
    • declaration to create a variable: newname variable;
  • Enumerated Types:
    • enum type1 {value1, value2, ...} enum1; type1 = enum2; enum2 =value2;
union id1 {
    type1 var1;
    type2 var2;
    struct {
        type3 var3;
        type4 var4;
    } struct1;
} union1,union2;
union1.var1 = value1;
id1 var6;

struct struct_type1 {
   type1 array1[20];
   type2 var2;
   type3 *var3;
   union {
    type4 var4;
    type5 var5;
  } union1;
} struct1, struct2;

struct_type1 struct3, struct4;

struct struct_type2 {
   type1 var1;
   union {
    type2 var2;
    type3 var3;
} struct1;

struct_type2 struct2; // struct2 is an object
struct_type2 *pstruct2; // pstruct2 is a pointer
pstruct2 = &struct2; // the value of the pointer is now the address of the object

cout << pstruct2->var1;// access the member var1 of the object from its address
cout << (*pstruct2).var2; //access the member var2 of the object from its address

  • A series of elements of the same type
  • Array indices begin with zero
type1 array1[7]; //declare of array1 array, with seven elements of type type1
type2 array2[value1, value2, value3]; // declaration and initialization
type3 array3[5] = {value1, value2, value3};
type4 array4[3] = {};
type5 array5 [] = {value1, value2, value3};

type6 array6 [2][5];
type7 array7 [2][3][5];

void function1 (type1 arg[], type1 var1){}
type8 array8[] ={value1, value2, value3};
function1 (array8, value1);