Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Part A

1. Flip over this test. On the back of this test write your name in the upper, left-hand corner.

2. What are the four parts of the compiling process (just give me 4 words, not a paragraph).

3. Which of the four steps of the compiling process occurs only once, regardless of the number of source files your application has?

4. Write a line of code that causes the preprocessor to generate an error.

5. Write a line of code that causes the compiler to generate an error.

6. Describe how you could incorrectly compile the joust project to cause the linker to generate an error.

7. Given:
1 float* fp;
2 //...
3 float pi;
4 pi=*(314 + fp);

Rewrite line 4 using array subscript notation.8. (5 points) Given:
1 float arr[100];
2 for(int x=0; x<100; ++x)
3 arr[x]=100-x;

What does the following expression print out?
cout << *arr << endl;

9. Given:
int a=0;
int b=6;
int x=0;
Circle each if-expression that evaluates to true:
A) if(b)
B) if(x)
C) if(a=b==6)
D) if(a=b==5)
E) if(a=b=5)
F) if(a=x=0)
G) if(a=x==0)

10. Given:
1 #include
2 using namespace std;
3
4 int main()
5 {
6 int x;
7 cout << "Enter a number greater than 10" << endl;
8 while ( x < 10 )
9 {
10 cin >> x;
11 }
12 return 0;
13 }

This program compiles just fine, and sometimes it runs as expected. But sometimes when you run it, it exits immediately after printing "Enter a number greater than 10". That is, the program doesn't pause for you to enter a number. Why are you getting this inconsistent behavior?

11. What is the output of the following:
int x=4;
int y=3;
A) cout << x / y << endl;
B) cout << x % y << endl;
C) cout << x << "%" << y << endl;
D) cout << "x" << '%' << 'y' << endl;

12. What is the type of the expression. That is, what is the kind of thing that each expression evaluates to. For example:
3 + 4 integer
You may assume that the variable a has been declared as an integer.
A. a + 4
B. a = 4
C. 3.14 + 4.49
D. 3 + 3.14
E. 'a'
F. cout << a
G. new float[30]
H. new float

13. Write a for-loop that prints out the numbers between 1 and 100 that are evenly divisible by three.

14. Write a while-loop that prints out the numbers between 1 and 100 that are evenly divisible by three.

15. Given:

1 #include
2
3 class Willow {
4 public:
5 Willow(int g);
6 private:
7 float f;
8 };
9
10 Willow::Willow(int g) : f(g)
11 {
12 }
13
14 void display(int g)
15 {
16 std::cout << g << std::endl;
17 }

Write a main-function that:

A. Creates a Willow object
B. Calls the display function

Part B

1. Write your name on the backside of the last page.

2. Every C++ program begins at the function ____________.

3. What is the difference between these 2 include statements.

#include
#include "iostream"

4. What is the expected output of the following piece of code?

int x = 5.7;
int y = 3.2;
cout << x-y;

5. Assuming we have three C++ file named main.cpp, test.h, and test.cpp, what command could we use to compile our code into an executable?

6. Name the 4 steps that occur when a program is compiled

7. Write the implementation file (person.cpp) for the following person.h file. The file must be complete and should compile.

#include
using namespace std;
class Person {
public:
Person(string, int); //should set private data members
string getName();
int getAge();
private:
string name;
int age;
};

8. What is the output of the following program?
#include
using namespace std;
void figureMeOut(int& x, int y, int& z);
int main( ) {
int a, b, c;
a = 10;
b = 20;
c = 30;
figureMeOut(a, b, c);
cout << a << " " << b << " " << c << endl;
return 0;
}
void figureMeOut(int& x, int y, int& z)
{
cout << x << " " << y << " " << z << endl;
x = 1;
y = 2;
z = 3;
cout << x << " " << y << " " << z << endl;
}

9. What is the purpose of a constructor? When does it run?

10. Why do you use #ifndef, #define, and #endif in a header file?

11. Describe the action of the new operator

12. Suppose you are writing a program the uses a stream called fin, which will be connected to an input file called "stuff1.txt" and a stream called fout, which will be connected to an output file called "stuff2.txt". How do you declare fin and fout? What include directive, if any, do you need to place in the program file?

13. What is wrong with the following piece of code?

int sampleArray[10];
for (int index = 1; index <= 10; index++)
sampleArray[index] = 3*index;

Part C

1. Write your name on the backside of the last page.

2. Given the function: void printMessage(string message); Answer the following questions
What is the function's return type?
List the formal parameter(s) of the function. Include the data type and name of each formal parameter.
Write a call/invocation of the function printMessage with the string "This is so easy!" as the argument.
Is the function decLaration or function definition shown above?

3. Given the statement: float* fp=new float[3];
To release this memory:
a) delete fp;
b) delete [] fp;
c) for(int i=0; i<3; ++i) delete fp[i];
d) delete fp[3]
e) delete float[3];

4. Given:
a=3;
b=4;
expression 1: a -= b;
expression 2: a =- b;
What's the difference between the first and second expressions
a) They are equivalent
b) First is positive and second is negative
c) Second is negative and first is positive
d) The second one doesn't compile
e) None of the above

5. Consider the program below in the test.cpp file
1. #include
2. using namespace std;
3. int main()
4. {
5. do {
6. cout << "give me an int: ";
7. int i;
8. cin >> i;
9. while (i < 0 II i > 10);
10. cout << "Thanks, i is " << i << endl;
11. return 0;
12.
This program has a bug. It will not compile and gives the compiler error of test.cpp:1e:28 error: 'is was not decLared in this scope
Identify what line number the bug is on and propose how to eliminate it. You're welcome to write on or alongside the code itself.

6. Given the statement
string* airpLane[25];
Describe what is created when this statement is executed. Be explicit in your answer.

7. Given an array of integers:
int myArray[20];
open a text file for writing called "arraycontents.txt" and then write a loop that will print all of the contents of the array to the file.

8. Carefully distinguish between the meaning and use of the dot operator "." and the scope resolution operator "::"

9. Suppose your program contains the following class, contained in automobile.h,
class Automobile
public:
Automobile(double prc, double prft); //sets private data members void setPrice(double prc);
void setProfit(double prft);
double getPrice( );
private:
double price;
double profit;
double getProfit( );
;
and suppose the main function of your program contains the following declarations
Automobile hyundai (3999.99, 299.50);
Automobile jaguar (38999.99, 3200.00);
Which of the following statements will compile in the main function of your program? Write YES or NO before each statement.
hyundai.price = 4999.99; jaguar. setPrice(30000.97); double aPrice, aProfit;
aPrice = jaguar.getPrice( );
aProfit = jaguar.getProfit( );
aProfit = hyundai.getProfit( );
hyundai = jaguar;

10. Write the implementation file (automobile.cpp) for the class contained in automobile.h, which is described in the previous question.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91348418
  • Price:- $40

Guranteed 36 Hours Delivery, In Price:- $40

Have any Question?


Related Questions in Computer Engineering

Question what are four important tactical tasks for a

Question: What are four important tactical tasks for a negotiator in a distributive situation to consider? Discuss one instance where you have been involved in distributed bargaining. What was the outcome? The response m ...

Scenario you have been asked to develop a company policy on

Scenario: You have been asked to develop a company policy on what should be done in the event of a data breach, such as unauthorized access to your company's customer database. What sort of process would you use to devel ...

What are the best practices to follow for microsoft windows

What are the best practices to follow for Microsoft Windows network security. Which two would you start with and why?

Task working with arrays in matlabnbspcreate a matlab

Task : Working with Arrays in MatLab  Create a MatLab script called a2taski.m that computes the following tasks. The answers will appear in the Workspace. To view the larger structures, e.g., matrix A in Part 1 double cl ...

Assignmentsuppose a particular fa called fin has the

Assignment Suppose a particular FA, called FIN, has the property that it had only one final state that was not the start state. During the night, vandals come and switch the + sign with the - sign and reverse the directi ...

Please help with anbspfunctionnbspcodesymbol to convert

Please help with a function  codeSymbol , to convert each mark to a symbol (A, B, C, D, E, F) and a code (7,6,5,4,3,2,1) according to the table below. And call it in the main function. Use the table below to determine th ...

Question suppose that x 00271 and y 608 are correctly

Question : Suppose that x* = 0.0271 and y* = 6.08 are correctly rounded versions of x and y to 3 digit mantissas. The smallest interval [a,b] that would contain x is [0.02705, 0.02715] since 0.0271 is between those numbe ...

Information systemsdirections answer the following if you

Information Systems Directions : Answer the following: If you were asked to develop a logical model of the registration system at a school, would it be better to use a top-down or bottom-up approach? Explain your reasoni ...

Understanding the digital revolution assignment - parchment

Understanding the Digital Revolution Assignment - Parchment Purgatory Overview - For this assignment, you will use skills acquired through practical laboratory exercises to automate a business process, and to visualize t ...

Question suppose that you are working with gps data from an

Question : Suppose that you are working with GPS data from an Excel spreadsheet and that you map it in ArcMap. However, you are surprised that the data points are in Australia instead of Chile? What could be the possible ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As