What are the four parts of the compiling process

Assignment Help Basic Computer Science
Reference no: EM13778255

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<iostream>
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<iostream>
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 <iostream>
#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 <string>
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 <iostream>
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 <iostream>
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.

Reference no: EM13778255

Questions Cloud

What is the simple predicate of the given sentence : What is the simple predicate of the following sentence? Which of the following is a complex sentence that contains a dependent adverbial clause?
Why ethics and confidentiality play an integral role : How the process will need to be altered for various special populations. Potential clients in need of case management at both settings. Why ethics and confidentiality play an integral role when working with clients
What is the indirect object in the given sentence : What is the indirect object in the following sentence? For her birthday, Jody bought Alice an angora sweater. Which one of the following words is an antonym of joyful?
How the problems associated with your special population : Identify the characteristics and specific needs of the selected special population. Describe how the problems associated with your special population can be resolved. What would happen if the population was left unattended and not managed properly
What are the four parts of the compiling process : Flip over this test. On the back of this test write your name in the upper, left-hand corner. What are the four parts of the compiling process
Flexibility of women in the workplace : After viewing Women as change agents in America: Part I, determine why Kathleen Christensen believes that the flexibility of women in the workplace is a social and structural issue. Identify some factors that have affected women's flexibility in t..
Do you think the rapid cash store should stay in business : From the standpoint of ethics, do you think The Rapid Cash Store should stay in business? Explain your reasoning
Brief summary of the data architecture of the company : Understand the challenges and evaluate the risks in managing the security of an information system  Critically analyse using a threat and risk assessment.
Cultural diversity in the us-culture shock : Read the additional articles for the chapter-especially the Nacirema example-before attempting this assignment. You may also find it helpful to revisit the excerpt in your textbook, "Cultural Diversity in the US - Culture Shock: The Arrival of the..

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Add an overloaded assignment operator

Add an overloaded assignment operator, a copy constructor to the Cube class, and a printCube member function in the attached lab6_ex2_copy_operator_starter.cpp. This starter is incomplete, you have to fill the right stuff in the blank in order to ..

  Task manager to recognize and troubleshoot problems

Which system resources are probable to be at root of problem? How can you use system tools, like the Task Manager, to help recognize and troubleshoot these problems?

  Write and explain the definition of composition in c++

Write and explain the definition of composition in C++ and how it is useful in writing object-oriented programming. Also, explain how it is different from inheritance and how both inheritance and composition are useful in developing object-oriente..

  Evaluating options and developing resolutions

Provide an overview of tasks and key work activities (meetings, training, presentations, etc.) in which you were engaged during the week, with sufficient detail for your instructor to understand what you were involved in.

  Consultant for being brought in by xumuc

You are a consultant for being brought in by XUMUC to assist with a merger with another company.

  Microsoft office component

Predict the microsoft office component and / or feature that you believe will be the most difficult for you to learn and explain why

  Determine the maximum number

Determine the maximum number Determine the range (maximum - minimum) Displays a histogram that shows the numbers in each five-unit range.

  Describe the five forces model

Describe the Five Forces Model. What role does the Five Forces Model play in decision making? Define a database management system and discuss each of the five important software components of a database management system.

  How applications of technology used to overcome barrier

Explain how applications of technology could be used as the means to overcome each of these barriers. Write at a minimum the applications which use word processing.

  Create a student class which will contain the following

Demonstrate the correct working of your classes by reading in a collection of student records from a file, sort the records, and print them. If a name is "EOF" it will mark the end of the file.

  Display the total annual compensation

A salesperson will continue to earn a fixed salary of $50,000. The current sales target for every salesperson is $80,000.

  Demonstrate method polymorphism

Write some usable code snippets that demonstrate method polymorphism.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd