CSAS 1111: Practice Exam 1
This exam contains questions that may appear in similar form in the actual exam. However, this does not imply that only questions of the type mentioned here will be part of the actual exam, or that the actual exam will include questions from this practice test. Also, this practice exam contains more questions that the actual exam.
- 1. Explain each of the following terms:
- Source code, machine code, compiling, linking, double, int, char, CPU, RAM, secondary memory, bit, byte, smallest/largest integer, passing by reference, passing by value
- 2. Write some C++ program segments that solves the indicated tasks (you do not have to write a complete program, a small code segment will be sufficient).
A program to decide whether a number is positive, negative, or zero | |
A program to print all integers from 1 to 50 on the screen | |
A program to print all odd integers from 1 to 50 on the screen | |
A program to output a small menu that looks like this Startreck Simulation Program A to fire phasers B to fire photon torpedos X to exit Enter your choice: | |
A program to reads a real number as input and adds it to a running total until the user enters the number -99. At that time the program should print out the final sum (not including, of course, the number -99). |
if ((Balance >= 2000) && (Balance <= 3000)) { cout << "Your balance is between $2000 and $3000"; cout << "Your interested rate will be 3.5%"; } else { cout << "Your balance is larger than $3000."; cout << "Your interest rate will be 4.5%"; }
the main functions should contain the appropriate variable declarations | |
Input/output could be done in the main function, or in seperate functions that are used in the main function | |
the user should be asked to enter the radius of the circle, either inside the main function, or with the help of an additional function | |
the computations of area and circumference must be handled in additional functions that the main function uses | |
the output of the area and the circumference could be handled inside the main function, or with the help of additional function(s) | |
all functions must appear in the proper order so that your entire program would compile, link, and run without errors. | |
note that the value of Pi is not known to C++, and must therefore be defined as a constant at the correct position of the program. |
When writing a C++ program, which function do you always write first ? | |
What are the three pieces usually necessary when using a while loop in C++ programming ? | |
When writing a C++ program, where does the definition of a new function go ? | |
In C++ programming, where does the declaration of a new variable belong ? | |
In C++ programming, what does the data type void stand for ? | |
In C++ programming, what is the difference between = and == ? | |
In C++ programming, what is the difference between a declaration and an assignment ? | |
What are the advantages and disadvantages of the data types int and double ? | |
What type do you always get when dividing or multiplying two integers ? How about if one of the factors, or the numerator or denominator, is a double ? |
void Unknown(double x, double& y, int I, int& J) { x = x + y; y = x + y; I = I + J; J = I + J; }
Which parameters are value parameters, which are reference parameters ? | |
What is the output when the function Unknown is used as in the code segment
below: double X = 1.0; double Y = 2.0; int I = 3; int J = 4; Unknown(X,Y,I,J); cout << X << Y << I << J; X = 1.0; Y = 2.0; I = 3; J = 4; Unknown(Y,X,J,I); cout << X << Y << I << J; |
#include <iostream.h> int main(void) { for (int i = 0; i < 5; i+=3) cout << "i=" << i << endl; for (int i = 1; i <= 2; i++) for (int j = 1; j < 5; j+=2) cout << " i * j=" << i*j << endl; double xx = 32; while (xx > 1.0) xx /= 2; cout << " xx=" << xx << endl; int i = 10; int j = 4; int k = i / j; double x = i / j; double y = ( (double)i / (double)j ); cout << " k=" << k << " , x=" << x << " , y=" << y << endl; return 0; } </PRE> </DL> </BLOCKQUOTE> </BODY> </HTML> ">