ProgrammingDeclarations
Programming Declarations
COMP102Prog.Fundamentalsl:Declarations/Slide2General form of a C++ program//Programdescription#include directivesint main()constant declarationsvariable declarationsexecutable statementsreturn0
COMP102 Prog. Fundamentals I: Declarations/ Slide 2 General form of a C++ program // Program description #include directives int main(){ constant declarations variable declarations executable statements return 0; }
COMP102Prog.Fundamentalsl:Declarations/Slide3C++ Data TypeA type defines a set of values and aset of operations that can be applied onThe set of values for eachthosevalues.type is known as the domain for the type.C++ contains 5 standard types:StandardDataTypesirntvaiddharfloatbod
COMP102 Prog. Fundamentals I: Declarations/ Slide 3 C++ Data Type A type defines a set of values and a set of operations that can be applied on those values. The set of values for each type is known as the domain for the type. C++ contains 5 standard types: void int char float bool Standard Data Types
COMP102Prog.Fundamentalsl:Declarations/Slide4voidThe void type has no values and nooperations.In other words, both the set ofvalues and the set of operations are emptyAlthough this might seem unusual, we willsee later that it is a very useful datatype
COMP102 Prog. Fundamentals I: Declarations/ Slide 4 void The void type has no values and no operations. In other words, both the set of values and the set of operations are empty. Although this might seem unusual, we will see later that it is a very useful data type
COMP102Prog.Fundamentalsl:Declarations/Slide5IntegerAn integer type is a number without afractional part.It is alsoknown as anintegral number. C++ supports three differentsizes of the integer data type: short int, intand long int.sizeof(short int)<= sizeof(int)<= sizeof(long int)Shortintintlongint
COMP102 Prog. Fundamentals I: Declarations/ Slide 5 Integer An integer type is a number without a fractional part. It is also known as an integral number. C++ supports three different sizes of the integer data type: short int, int and long int. sizeof(short int)<= sizeof(int)<= sizeof(long int) Short int int long int