one function calling another
arrays
subscript nation
parameters (header value): 5 1 2 3 4 5. For example that says 5 numbers
will be entered, and the numbers 1 to 5 are there. So the first 5 is a
header value.
casting of variables.
placing items in an array using a switch statement
array as parameter to a function
using an array in a function
two dimensonal arrays - such as class average.
Passing an arrary to a function
Passing a two dimensonal arrary to a function
sorting data in an array
finding the maximum number in an array listing.
for loop for an array
Detecting the end of a set of data:
- Trailer value (like -1)
- User Response y/n
- The parameter or header method (indicating the amount of data).
- EOF to detect end of the set of data. Ctrl-Z
parameters which are refernece parameters. Incrementing a number.
Swapping numbers.
input & output parameters for a function using multiple pointers.
string - string functions
length (size), insert, replace, erase, find, subst, c_str - web link
getline
get & put
cctype - isalpha(), isdigit(), isspace(), ispunct(), islower(),
isupper(), isalnum(), toupper(), tolower() - page 455
line-oriented vs token-oriented input/output
character functions
strings as parameters
positions of characters in an array
splitting the string into sub strings.
charater-oriented IO
arrays of strings
flags in loops
Sample Questions:
int grades[4[={90,100,95,80};
Using a for loop, write out all the values in the array grades.
Write a function called average that will take
an array, calcuate the average, and then return that value....be
careful when dealing with ints for an average.
string name="Lawrence";
Using a for loop, write out all the letters in the name, one
letter on each line.
int ages[10];
Write a function called set_ages, that will take the ages
array, an age, and a parameter of the size of the array and set all the
elements in the array to be the same age.
Such as to set all the ages to 21.
int scores[10];
int min,max;
Write a function that will take the scores
array,
and min and max as reference parameters. The function will set min and
max to be
equal to the lowest and highest values of the scores array.
For the same array, make a function called sort_scores to place
the scores from lowest to highest. Use any sorting technique like you.
Discuss 4 ways of:
Detecting the end of a set of data
I have an array called numbers
which can hold 10 integers. Write a small program that reads in 10
numbers from
the keyboard to fill up the array.
What is the result of the
following:
#include <iostream>
#include <string>
using namespace std;
int main() {
string word="Goats";
string sentence=" loves
oats";
int position;
position=sentence.find("v",0);
cout << word.length()
<< endl;
cout << position <<
endl;
sentence.replace(7,5,"sushi");
cout <<
sentence.substr(7,5) << endl;
sentence.insert(0,word);
cout << sentence
<< endl;
sentence.erase(0,6);
cout << sentence
<< endl;
}
#include <iostream>
#include <string>
using namespace std;
int main() {
string word="Roast";
string name="Lawrence";
word=name;
cout << word << endl;
cout << name << endl;
name = "Perry";
cout << word << endl;
cout << name << endl;
}
Vowel counting:
Using a character array that can hold up to 100 characters:
Write a program to ask the user to enter in a word and then display out
the number of vowels (a,e,i,o,u,y) that are contained in the word.
Be careful of the
cases of the letters. For example, count both A and a.
After each word's vowel count is displayed, use a character prompt
cin.get()
to ask the user if they want to enter another
word.
How could you test a string after
it was read in to see if was read in successfully?
Keep
on the look out for more sample questions