COS1511_Nov2016_MEMO TUTORIALS CAMPUS www.tutorialscampus.co.za
1.1 45
1.2 Twice
1.3 0
1.4 6
1.5 7
1.6 Name.size()
1.7 0
1.8 Classic basic primitive types may include:
Character (character, char);
Integer (integer, int, short, long, byte) with a variety of precisions;
Floating-point number (float, double, real, double precision);
Boolean, logical values true and false
1.9 SAfrica
1.10 #include <iostream>
Question 2)
2.1) To add all the even numbers in the array to sum variable, and display sum
2.2) To accept values to variable a and b, swap the values in the variables and display the
variables.
Question 3)
3.1)
if(level == 1 || level == 2)
cout<<"Basic";
else if(level == 3)
cout<<"Intermediate";
else if(level == 4)
cout<<"Advance";
else
cout<<"Not a valid level";
3.2)
A prime number is a whole number greater than 1, whose only two whole-number factors are 1
and itself. The first few prime numbers are 2, 3, 5, 7, 11, 13, 17, 19, 23, and 29.
int i=2, j;
1|Page -)For more info call Nicholas on 083 33 13 124
, COS1511_Nov2016_MEMO TUTORIALS CAMPUS www.tutorialscampus.co.za
bool prime = true;
while(i < 10)
{
prime = true;
j = 2;
while(j<i)
{
if((i%j) == 0)
prime = false;
j++;
}
if(prime)
cout<<i<<endl;
i++;
}
4.1)
A named memory location used to store data of a specific datatype
4.2)
Global variable are variables which are declared outside all function and can be accessed by all
the functions within that program.
Local variable are variable which are declared within a function or block of code(e.g for_loop)
and are visible within that function or block.
4.3)
float f1;
4.4)
A function is a group of statements that together perform a task. A function declaration
tells the compiler about a function's name, return type, and parameters. A function
definition provides the actual body of the function.
4.5)Refer to Appendix D of the leaner guide, page 376
getline(istream, string &, char)
srand(int)
int rand( )
char tolower(char)
4.6)
Acutal parameters are values in a function calling statement that are passed to the function
being called.
Formal are parameter are variables in the function definition that are used to receive values for
that function.
2|Page -)For more info call Nicholas on 083 33 13 124
1.1 45
1.2 Twice
1.3 0
1.4 6
1.5 7
1.6 Name.size()
1.7 0
1.8 Classic basic primitive types may include:
Character (character, char);
Integer (integer, int, short, long, byte) with a variety of precisions;
Floating-point number (float, double, real, double precision);
Boolean, logical values true and false
1.9 SAfrica
1.10 #include <iostream>
Question 2)
2.1) To add all the even numbers in the array to sum variable, and display sum
2.2) To accept values to variable a and b, swap the values in the variables and display the
variables.
Question 3)
3.1)
if(level == 1 || level == 2)
cout<<"Basic";
else if(level == 3)
cout<<"Intermediate";
else if(level == 4)
cout<<"Advance";
else
cout<<"Not a valid level";
3.2)
A prime number is a whole number greater than 1, whose only two whole-number factors are 1
and itself. The first few prime numbers are 2, 3, 5, 7, 11, 13, 17, 19, 23, and 29.
int i=2, j;
1|Page -)For more info call Nicholas on 083 33 13 124
, COS1511_Nov2016_MEMO TUTORIALS CAMPUS www.tutorialscampus.co.za
bool prime = true;
while(i < 10)
{
prime = true;
j = 2;
while(j<i)
{
if((i%j) == 0)
prime = false;
j++;
}
if(prime)
cout<<i<<endl;
i++;
}
4.1)
A named memory location used to store data of a specific datatype
4.2)
Global variable are variables which are declared outside all function and can be accessed by all
the functions within that program.
Local variable are variable which are declared within a function or block of code(e.g for_loop)
and are visible within that function or block.
4.3)
float f1;
4.4)
A function is a group of statements that together perform a task. A function declaration
tells the compiler about a function's name, return type, and parameters. A function
definition provides the actual body of the function.
4.5)Refer to Appendix D of the leaner guide, page 376
getline(istream, string &, char)
srand(int)
int rand( )
char tolower(char)
4.6)
Acutal parameters are values in a function calling statement that are passed to the function
being called.
Formal are parameter are variables in the function definition that are used to receive values for
that function.
2|Page -)For more info call Nicholas on 083 33 13 124