GRADE (TA use only) __________________
(1 point) USER NAME: ___________________________
if(x != 23 && y)
x++;
else if(x < 0 || y == 23)
y--;
else x += y;
cout << x << " " << y << endl;
if(x / y && y != 0)   cout << x / y << endl;
if(x < y && y > x) cout << "Not good.\n";
cout << "Carry on.\n";
if(x < y && y >= x) cout << "Not good.\n";
cout << "Carry on.\n";
if(x < y || y >= x) cout << "Not good.\n";
cout << "Carry on.\n";
x = 5; y = 5;
if (y <= x)
if (x > 8)
x++;
else
y--;
cout << x << " " << y << endl; x = 5; y = 5;
if (y <= x) {
if (x > 8)
x++;
}
else
y--;
cout << x << " " << y << endl; x = 4; y = 8;
if (y <= x)
if (x > 8)
x++;
else
y--;
cout << x << " " << y << endl; x = 4; y = 8;
if (y <= x) {
if (x > 8)
x++;
}
else
y--;
cout << x << " " << y << endl; cout << " Please enter an integer ";
cin >> x;
switch(x) {
case 60: x--; x--; break;
case 5: x = x * x;
case 31: x--; break;
case 25: x = 33;
case 24: x += 4;
default: x++;
}
cout << x << endl;
cin >> x >> y;
if (x > 5)
if (y < 3)
cout << "Electrical\n";
else
cout << "Engineering\n";
else
if (y > 4)
cout << "Computer\n";
else
cout << "Science\n";
#include<iostream>
using namespace std;
void func(int, int);
int main()
{
int x, y, z;
x = 30; y = 34; z = 38;
func(x, y);
cout << "In main: " << x << " " << y << " " << z << endl;
}
void func(int x, int b) {
int z;
x = 75; b = 77; z = 72;
cout << "In func: " << x << " " << b << " " << z << endl;
}
int mystery(int x)
{
return x % 100;
}
for(i = 0; i < 3; i++) {
cin >> cents;
cout << cents << " ";
}
cout << endl << i << " " << cents << endl;
for(i = 2, x = 1; i <= 10 && x <= 20; i++)
x = x * i;
cout << x << " " << i << endl;
// file Circle.h
const double PI = 3.14159;
class Circle {
public:
// *** WRITE A PROTOTYPE FOR MEMBER FUNCTION circumference().
// compute and return area (PI times radius squared)
double area();
// declare constructor
Circle(double r);
private:
double radius; // radius of circle in feet
};
#include <iostream>
#include "Circle.h"
using namespace std;
int main()
{
// *** CREATE A Circle OBJECT o_shape AND PASS 10.14 TO Circle CONSTRUCTOR
// print area and circumference
cout << "Area: " << o_shape.area() << endl;
cout << "Circumference: " << o_shape.circumference() << endl;
}
// Implement Constructor for Circle
Circle::Circle(double r) {
radius = r;
}
// *** IMPLEMENT area MEMBER FUNCTION
double Circle::area() {
}
double Circle::circumference() {
return PI * 2 * radius;
}
for(i = -374; i < 528; i += 10)
process(i);
CS 102 Test 1 October 2, 2007
1. 1. #define PI 3.14159
2. const int NUM = 100;
2. 1. -48 -1
2. 34 55
3. 17 23
3. 1. if(y != 0 && x /y) cout << x / y << endl;
2. if(x < y) cout << "Not good.\n";
cout << "Carry on.\n";
-OR- if(y > x) cout << "Not good.\n";
cout << "Carry on.\n";
3. if(x < y) cout << "Not good.\n";
cout << "Carry on.\n";
4. if(y >= x) cout << "Not good.\n";
cout << "Carry on.\n";
4. 1. 5 4
2. 5 5
3. 4 8
4. 4 7
5. 1. 58
2. 24
3. 29
6. 1. x > 5 and y < 3
2. x > 5 and y >= 3
3. x <= 5 and y > 4
4. x <= 5 and y <= 4
7. In func: 75 77 72
In main: 30 34 38
8. 1. mystery( ) returns the two rightmost digits of the argument.
2. int mystery(int); -OR- int mystery(int identifier);
9. 1. int maximum(int x, int y, int z)
{
int max; // ultimately, holds max value
max = x; // assume the largest is x
if(y > max) max = y;
if(z > max) max = z;
return max;
}
2. cout << "The maximum is " << maximum(x, y, z) << ".\n";
10. 0.56 0.44 0.22
3 0.22
11. 1. 24 5
2. i = 2; x = 1;
while(i <= 10 && x <= 20) {
x = x * i;
i++;
}
cout << x << " " << i << endl;
12. double circumference();
Circle o_shape(10.14);
return PI * radius * radius;
BONUS 1. 91
2. 536