cout<<"This is the last coding club meeting"<<endl;
This is the last coding club meeting
"dolphin"
String
What do you put at the end of each line?
semicolon (;)
string my_string = "Hello World";
my_string[0]
H
cout<<"What is your favorite food?;
The second quotation mark is missing
string seasons = "winter";
string season = "summer"
cout<<"My favorite season is "<<seasons << " and my least favorite season is << season;
My favorite season is winter and my least favorite season is summer
What data type does this list consist?
["c","r","q","z",k"]
Char
What do you include at the top of each coding lab you do?
using namespace std;
list<str> my_list = ("sleep ", "turtle ", "love ", "hate ", "apple ", "butterfly ");
cout<<my_list[5]<<my_list[2]<<mylist[0];
butterflylovesleep
string hello = "hello";
Cout<<hello< " world"<<endl;
int num1 = 9
int num2 = 5
if(num1<num2){
cout<<"Are you sure you are correct?";
}
else{
cout<<"Check your work again.";
}
Check your work again.
What is the difference between a float and an integer?
integer is without a decimal point and float is a number with a decimal point
What is important to remember about writing functions?
It is important to include it at the top of your code so that it is defined before you use it.
list <str> alphabet = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");
cout<<alphabet[7]<<alphabet[4]<<alphabet[11]<<alphabet[18];
hels
number. = 12;
cout << "My favorite number is."<<number;
No variable type is states which in this case is an int
for(int i=4; i<=20; i+=3){
cout<<"pizza is good"<<endl;
i++;
}
pizza is good
pizza is good
pizza is good
pizza is good
pizza is good
What is modulo?
Modulo is the remainder when you divide something.
What data type is main, and what do you use it for?
The data type is a function, and it is where you write all of your code besides other functions.
string word = "Is this a question?"
How would I slice the string word to get the output "this a"?
word.substr(3,6)
int num=9
int NNM=12;
if(num>NNM){
cout<<"The numbers added together is "<<NNMnum endl;
};
esle{
cout<<"The numbers subtracted is "<<num-NNM;
};
1. No semicolon after 9
2. Missing the addition sign in the first if statement
3. Semicolon after both the brackets in the if and the else
4. else is spelled wrong
NOTE: Numbers entered are 24 & 30 respectively
int function(int num, int numm);
int main()
{
int numm, num;
cout<<"Enter first number: ";
cin>>num;
cout<<endl<<"Enter second number: ";
cin>>numm;
int maths = function(numm, num);
cout<<endl<<maths;
}
int function(int num, int numm){
int math = num - numm;
return math;
}
6
When would integer division apply, and when would float division happen?
Integer divison would happen if both the numbers are integers, and float division would happen is one number is a float.
What are the different return types for functions and what do they do?
string: returns a string
int: returns an integer
float: returns a float
char: returns a char
void: returns nothing
What would be printed out (kind of less of an indexing question lol)
indexer("Coding club 2024")
void indexer(str word){
for (int i = 1; i<word.size(); i+=2)
{
cout<<word[i];
}
}
oigcu 04
int main
{
int numm, num;
cout<<"Enter first number: ";
cin>>num;
cout<<end<<"Enter second number: ";
cin>>Numm;
int maths = function(numm, num);
cout<<endl<<maths;
}
int function( num, numm){
int math = num numm;
return math;
}
1. Does not call function before the main function
2. Missing the paranthesis after 'main'
3. endl is spelled wrong
4. The variable 'numm' is spelled wrong
5. int is missing in the paranthesis of function
6. A math sign is missing