Declare a variable called age to hold a person's age and set it to be 21.


Declare a variable called pi to hold a value of 3.14.


Declare an array called grades and the array to hold the values 90,100,95.


Declare a string called name to hold your name.


Declare a char called true and set it to the value T.


Modify an array called numbs that has 3 values. Set the 1st position in the array to be the sum of the 2nd and 3rd values.


Declare a char called letter to be equal to the 5th character (remember character positions) in the string called word.


Using string functions, create a string called word that gets the substring of “view” from a string called sentence. sentence has the value of “Final Exam Review”.


Take an array called prices which has item prices (up to 6 prices, which can include dollars and cents) and set all the prices to be 1.99.


Take an array of 10 integers called numbers and set the 1st to be 10 and the 2nd to be 15. Set the 3rd through 10th ones equal to the sum of the previous two. So for example the 3rd gets the value of 25 (10+15). The 4th gets the value of 40 (15+25).

Declare array, and set the 1st and 2nd values. Use a for-loop to write the code of setting the 3rd through the 10th.



Write the prototypes for the following:


A function called zoo gets two strings passed to it and returns a string.


A function called tree gets two integers passed to it and returns nothing.


A function called process gets two integers passed to it and returns a double.


A function called letter gets a string passed to it and returns a character.


A function called modify gets a reference parameter to an integer and nothing.


A function called nothing, gets no parameter and returns nothing.


A function called huh, gets no parameter and returns an integer.



Create a program that will open a file for reading and read in a series of integers. The file name to open will be called “data.txt”. You can read in up to 100 integers from the file. Detect the end of file (EOF) to know when the file is at the end. But also note, that if the user has more than 100 integers only read in the first 100. You may use cin to read the values from the file.


Create a function called sort_it that gets the array, and the size of the array (how many values got read in) and then the function will sort the values of the array in ascending order.


Create a function called print_it that gets the array, the size of the array (how many values are in the array) and then the array is printed.


Main reads in from the file the numbers, keeping track of how many values are read in. Then the file is closed. Then main calls the array sort_it to sort the array. Then main calls the function print_it.




Create a program that has the user enter in integer values from the keyboard. After the user enters a value the value is stored to a file. The program keeps track of the maximum and minimum values entered.


The user enters in a -1 to indicate the end of the data entry. After the user finishes their data entry, the program calculates the average for the numbers as a double value.


The maximum and minimum values are written to the file. The average value is also written to the file.


Use the filename as “output.txt” to store the information. Do not forget to close the file when you are done.



Create a class for a soda machine. The item has the following information:


Item:

Price

Description


Price:

Retail (dollars & cents)

Wholesale (dollars & cents)


Description:

Product Name

Ounces (whole numbers)

Calories (whole numbers)


Write out the class definition for an Item class, making use of other classes.


Declare an item called drink and set all the price and description values by having the user enter them in from the keyboard. Then display the amount of calories per ounce the drink contains.



What is the output of the following:


int weird(int &k, int j) {

    int m;

    m=j-k;

    if(m==k*2) {

        j=5;

        k=50;

    }


    else k=10;

    return m;

}


int main() {

    int a=5, b=20, c= 60;

    int z;


    z=weird(a,b);


    cout << z << " " << a << " " << b << " " << c << endl;


    z=weird(b,c);


    cout << z << " " << a << " " << b << " " << c << endl;

}



What is the output of the following:


int main() {

    int x[5];


    x[0]=2;

    for (int i=1;i<5;i++)

        x[i]=x[i-1]*2-i;


    for (int i=0;i<5;i++)

        cout << x[i] << endl;


    cout << endl;

    x[5]=x[0];

    x[0]=100;


    for (int i=5;i>0;i--)

        x[i]=i*x[0];

    x[0]=0;


    for (int i=0;i<5;i++)

        cout << x[i] << endl;

}



What is the output of the following:

int main() {

string funny = "Nanoo Nanoo";

string odd = "Mork from Ork";

string word;

int location;


word = odd.substr(10,3);


cout << word << endl;


word="Hey";


cout << word << endl;


location=funny.find("a",0);


cout << location << endl;


cout << funny.size() << endl;


if(funny > odd)

    cout << funny << endl;

else cout << odd << endl;


funny[2]=funny[8]='b';


cout << funny << endl;


funny.erase(0,8);

cout << funny << endl;


odd[4]='\t';

odd[9]='\n';


cout << odd << endl;

}

What is the output of the following:

int main() {

int i=5;

double price=10.99;

string name="jon";


if(name=="joe" && price <11)

    cout << "Hey" << endl;


if(name=="joe" && price <11 || i==5)

    cout << "Hello" << endl;


if(price - .99 == 10 )

    cout << "Price" << endl;


if(price + .01 != 11)

    cout << "Tax" << endl;

else if (name == "jon")

    cout << "Garfield" << endl;


if(i*2 < 3)

    cout << "Boo" << endl;

else if (i==2)

    cout << "Whoo" << endl;

else {

    i+=10;

    cout << "Pie " << i << endl;

}

}