SlideShare une entreprise Scribd logo
1  sur  17
Spring 2014 CSCI 111 Final exam � of �1 6
1. (2 points) Flip over this test. On the back of this test write
your name in the upper, left-hand
corner.
2. (2 points) What are the four parts of the compiling process
(just give me 4 words, not a
paragraph).
3. (4 points) Which of the four steps of the compiling process
occurs only once, regardless of
the number of source files your application has?
4. (4 points) Write a line of code that causes the preprocessor to
generate an error.
5. (4 points) Write a line of code that causes the compiler to
generate an error.
6. (5 points) Describe how you could incorrectly compile the
joust project to cause the linker to
generate an error.
7. (5 points) Given:
1 float* fp;
2 //...
3 float pi;
4 pi=*(314 + fp);
Rewrite line 4 using array subscript notation.
Spring 2014 CSCI 111 Final exam � of �2 6
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. (14 points) 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)
Spring 2014 CSCI 111 Final exam � of �3 6
10. (10 points) 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. (4 points) 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;
Spring 2014 CSCI 111 Final exam � of �4 6
12. (16 points) 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
Spring 2014 CSCI 111 Final exam � of �5 6
13. (5 points) Write a for-loop that prints out the numbers
between 1 and 100 that are evenly
divisible by three.
14. (5 points) Write a while-loop that prints out the numbers
between 1 and 100 that are evenly
divisible by three.
15. (5 points) Write a do-while-loop that prints out the numbers
between 1 and 100 that are
evenly divisible by three.
Spring 2014 CSCI 111 Final exam � of �6 6
16. (10 points) 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
CSCI 111, Fall 2013, Final Exam
You do NOT have to write complete programs to answer the
questions below,
unless the question asks explicitly that you do so.
1. (2 points) Write your name on the backside of the last page.
2. (8 points) 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. (5 points) 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.(5 points) 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.(10 points) 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 || 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:10:28 error: ’i’ 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.(10 points) Given the statement
string* airplane[25];
Describe what is created when this statement is executed. Be
explicit in your
answer.
7. (10 points) 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. (10 points) Carefully distinguish between the meaning and
use of the dot
operator “.” and the scope resolution operator “::”
9. (15 points) 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. (25 points) Write the implementation file (automobile.cpp)
for the class
contained in automobile.h, which is described in the previous
question.
CSCI 111, Spring 2013, Final Exam
1. (1 point) Write your name on the backside of the last page.
2. (1 point) Every C++ program begins at the function
____________.
3. (4 point) What is the difference between these 2 include
statements.
#include <iostream>
#include “iostream”
4. (2 point) What is the expected output of the following piece
of code?
int x = 5.7;
int y = 3.2;
cout << x-y;
5. (3 point) 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. (4 point) Name the 4 steps that occur when a program is
compiled
1.
2.
3.
4.
7. (10 point) 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. (5 point) 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. (4 point) What is the purpose of a constructor? When does it
run?
10. (3 point) Why do you use #ifndef, #define, and #endif in a
header file?
11. (2 point) Describe the action of the new operator
12. (3 point) 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. (2 point) What is wrong with the following piece of code?
int sampleArray[10];
for (int index = 1; index <= 10; index++)
sampleArray[index] = 3*index;

Contenu connexe

Similaire à Spring 2014 CSCI 111 Final exam of 1 61. (2 points) Fl.docx

Presentation 2 (1).pdf
Presentation 2 (1).pdfPresentation 2 (1).pdf
Presentation 2 (1).pdfziyadaslanbey
 
2. Data, Operators, IO.ppt
2. Data, Operators, IO.ppt2. Data, Operators, IO.ppt
2. Data, Operators, IO.pptswateerawat06
 
2. Data, Operators, IO (5).ppt
2. Data, Operators, IO (5).ppt2. Data, Operators, IO (5).ppt
2. Data, Operators, IO (5).pptElisée Ndjabu
 
C programming session 01
C programming session 01C programming session 01
C programming session 01Dushmanta Nath
 
Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)Hermann Hueck
 
U19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).pptU19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).pptManivannan837728
 
Md university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab newMd university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab neweyavagal
 
Md university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab newMd university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab newLast7693
 
Md university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab newMd university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab newscottbrownnn
 
Cis 170 c ilab 5 of 7 arrays and strings
Cis 170 c ilab 5 of 7 arrays and stringsCis 170 c ilab 5 of 7 arrays and strings
Cis 170 c ilab 5 of 7 arrays and stringsCIS321
 
Seminar 2 coding_principles
Seminar 2 coding_principlesSeminar 2 coding_principles
Seminar 2 coding_principlesmoduledesign
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4Saranya saran
 
Devry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and stringsDevry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and stringsshyaminfo04
 
Devry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and stringsDevry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and stringsash52393
 
Devry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and stringsDevry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and stringsjody zoll
 
Term 2 CS Practical File 2021-22.pdf
Term 2 CS Practical File 2021-22.pdfTerm 2 CS Practical File 2021-22.pdf
Term 2 CS Practical File 2021-22.pdfKiranKumari204016
 

Similaire à Spring 2014 CSCI 111 Final exam of 1 61. (2 points) Fl.docx (20)

Presentation 2 (1).pdf
Presentation 2 (1).pdfPresentation 2 (1).pdf
Presentation 2 (1).pdf
 
2. Data, Operators, IO.ppt
2. Data, Operators, IO.ppt2. Data, Operators, IO.ppt
2. Data, Operators, IO.ppt
 
2. Data, Operators, IO (5).ppt
2. Data, Operators, IO (5).ppt2. Data, Operators, IO (5).ppt
2. Data, Operators, IO (5).ppt
 
C programming session 01
C programming session 01C programming session 01
C programming session 01
 
Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)
 
U19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).pptU19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).ppt
 
Md university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab newMd university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab new
 
Md university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab newMd university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab new
 
Md university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab newMd university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab new
 
Cis 170 c ilab 5 of 7 arrays and strings
Cis 170 c ilab 5 of 7 arrays and stringsCis 170 c ilab 5 of 7 arrays and strings
Cis 170 c ilab 5 of 7 arrays and strings
 
What is c
What is cWhat is c
What is c
 
Seminar 2 coding_principles
Seminar 2 coding_principlesSeminar 2 coding_principles
Seminar 2 coding_principles
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4
 
Devry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and stringsDevry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and strings
 
Devry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and stringsDevry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and strings
 
Python Manuel-R2021.pdf
Python Manuel-R2021.pdfPython Manuel-R2021.pdf
Python Manuel-R2021.pdf
 
Devry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and stringsDevry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and strings
 
Term 2 CS Practical File 2021-22.pdf
Term 2 CS Practical File 2021-22.pdfTerm 2 CS Practical File 2021-22.pdf
Term 2 CS Practical File 2021-22.pdf
 
pythonQuick.pdf
pythonQuick.pdfpythonQuick.pdf
pythonQuick.pdf
 
python notes.pdf
python notes.pdfpython notes.pdf
python notes.pdf
 

Plus de rafbolet0

Summarize the key ideas of each of these texts and explain how they .docx
Summarize the key ideas of each of these texts and explain how they .docxSummarize the key ideas of each of these texts and explain how they .docx
Summarize the key ideas of each of these texts and explain how they .docxrafbolet0
 
Submit, individually, different kinds of data breaches, the threats .docx
Submit, individually, different kinds of data breaches, the threats .docxSubmit, individually, different kinds of data breaches, the threats .docx
Submit, individually, different kinds of data breaches, the threats .docxrafbolet0
 
Submit your personal crimes analysis using Microsoft® PowerPoi.docx
Submit your personal crimes analysis using Microsoft® PowerPoi.docxSubmit your personal crimes analysis using Microsoft® PowerPoi.docx
Submit your personal crimes analysis using Microsoft® PowerPoi.docxrafbolet0
 
Submit two pages (double spaced, 12 point font) describing a musical.docx
Submit two pages (double spaced, 12 point font) describing a musical.docxSubmit two pages (double spaced, 12 point font) describing a musical.docx
Submit two pages (double spaced, 12 point font) describing a musical.docxrafbolet0
 
Submit the rough draft of your geology project. Included in your rou.docx
Submit the rough draft of your geology project. Included in your rou.docxSubmit the rough draft of your geology project. Included in your rou.docx
Submit the rough draft of your geology project. Included in your rou.docxrafbolet0
 
Submit your paper of Sections III and IV of the final project. Spe.docx
Submit your paper of Sections III and IV of the final project. Spe.docxSubmit your paper of Sections III and IV of the final project. Spe.docx
Submit your paper of Sections III and IV of the final project. Spe.docxrafbolet0
 
Submit the finished product for your Geology Project. Please include.docx
Submit the finished product for your Geology Project. Please include.docxSubmit the finished product for your Geology Project. Please include.docx
Submit the finished product for your Geology Project. Please include.docxrafbolet0
 
Submit the Background Information portion of the final project, desc.docx
Submit the Background Information portion of the final project, desc.docxSubmit the Background Information portion of the final project, desc.docx
Submit the Background Information portion of the final project, desc.docxrafbolet0
 
Submit Files - Assignment 1 Role of Manager and Impact of Organizati.docx
Submit Files - Assignment 1 Role of Manager and Impact of Organizati.docxSubmit Files - Assignment 1 Role of Manager and Impact of Organizati.docx
Submit Files - Assignment 1 Role of Manager and Impact of Organizati.docxrafbolet0
 
SSChaSimple RegressionSimple Regressionpter C.docx
SSChaSimple RegressionSimple Regressionpter  C.docxSSChaSimple RegressionSimple Regressionpter  C.docx
SSChaSimple RegressionSimple Regressionpter C.docxrafbolet0
 
SRF Journal EntriesreferenceAccount TitlesDebitsCredits3-CType jou.docx
SRF Journal EntriesreferenceAccount TitlesDebitsCredits3-CType jou.docxSRF Journal EntriesreferenceAccount TitlesDebitsCredits3-CType jou.docx
SRF Journal EntriesreferenceAccount TitlesDebitsCredits3-CType jou.docxrafbolet0
 
srcCommissionCalculation.javasrcCommissionCalculation.javaimpo.docx
srcCommissionCalculation.javasrcCommissionCalculation.javaimpo.docxsrcCommissionCalculation.javasrcCommissionCalculation.javaimpo.docx
srcCommissionCalculation.javasrcCommissionCalculation.javaimpo.docxrafbolet0
 
SPSS Assignment Data.savWeek 6, Using Marketing Channel.docx
SPSS Assignment Data.savWeek 6, Using Marketing Channel.docxSPSS Assignment Data.savWeek 6, Using Marketing Channel.docx
SPSS Assignment Data.savWeek 6, Using Marketing Channel.docxrafbolet0
 
SQLServerFilesCars.mdf__MACOSXSQLServerFiles._Cars.mdf.docx
SQLServerFilesCars.mdf__MACOSXSQLServerFiles._Cars.mdf.docxSQLServerFilesCars.mdf__MACOSXSQLServerFiles._Cars.mdf.docx
SQLServerFilesCars.mdf__MACOSXSQLServerFiles._Cars.mdf.docxrafbolet0
 
Square, Inc. is a financial services, merchant services aggregat.docx
Square, Inc. is a financial services, merchant services aggregat.docxSquare, Inc. is a financial services, merchant services aggregat.docx
Square, Inc. is a financial services, merchant services aggregat.docxrafbolet0
 
SQL SQL 2) Add 25 CUSTOMERSs so that you now have 50 total..docx
SQL SQL 2) Add 25 CUSTOMERSs so that you now have 50 total..docxSQL SQL 2) Add 25 CUSTOMERSs so that you now have 50 total..docx
SQL SQL 2) Add 25 CUSTOMERSs so that you now have 50 total..docxrafbolet0
 
SPSS InputStephanie Crookston, Dominique.docx
SPSS InputStephanie Crookston, Dominique.docxSPSS InputStephanie Crookston, Dominique.docx
SPSS InputStephanie Crookston, Dominique.docxrafbolet0
 
Spring  2015  –  MAT  137  –Luedeker       Na.docx
Spring  2015  –  MAT  137  –Luedeker        Na.docxSpring  2015  –  MAT  137  –Luedeker        Na.docx
Spring  2015  –  MAT  137  –Luedeker       Na.docxrafbolet0
 
Springdale Shopping SurveyThe major shopping areas in the com.docx
Springdale Shopping SurveyThe major shopping areas in the com.docxSpringdale Shopping SurveyThe major shopping areas in the com.docx
Springdale Shopping SurveyThe major shopping areas in the com.docxrafbolet0
 
Springfield assignment InstructionFrom the given information, yo.docx
Springfield assignment InstructionFrom the given information, yo.docxSpringfield assignment InstructionFrom the given information, yo.docx
Springfield assignment InstructionFrom the given information, yo.docxrafbolet0
 

Plus de rafbolet0 (20)

Summarize the key ideas of each of these texts and explain how they .docx
Summarize the key ideas of each of these texts and explain how they .docxSummarize the key ideas of each of these texts and explain how they .docx
Summarize the key ideas of each of these texts and explain how they .docx
 
Submit, individually, different kinds of data breaches, the threats .docx
Submit, individually, different kinds of data breaches, the threats .docxSubmit, individually, different kinds of data breaches, the threats .docx
Submit, individually, different kinds of data breaches, the threats .docx
 
Submit your personal crimes analysis using Microsoft® PowerPoi.docx
Submit your personal crimes analysis using Microsoft® PowerPoi.docxSubmit your personal crimes analysis using Microsoft® PowerPoi.docx
Submit your personal crimes analysis using Microsoft® PowerPoi.docx
 
Submit two pages (double spaced, 12 point font) describing a musical.docx
Submit two pages (double spaced, 12 point font) describing a musical.docxSubmit two pages (double spaced, 12 point font) describing a musical.docx
Submit two pages (double spaced, 12 point font) describing a musical.docx
 
Submit the rough draft of your geology project. Included in your rou.docx
Submit the rough draft of your geology project. Included in your rou.docxSubmit the rough draft of your geology project. Included in your rou.docx
Submit the rough draft of your geology project. Included in your rou.docx
 
Submit your paper of Sections III and IV of the final project. Spe.docx
Submit your paper of Sections III and IV of the final project. Spe.docxSubmit your paper of Sections III and IV of the final project. Spe.docx
Submit your paper of Sections III and IV of the final project. Spe.docx
 
Submit the finished product for your Geology Project. Please include.docx
Submit the finished product for your Geology Project. Please include.docxSubmit the finished product for your Geology Project. Please include.docx
Submit the finished product for your Geology Project. Please include.docx
 
Submit the Background Information portion of the final project, desc.docx
Submit the Background Information portion of the final project, desc.docxSubmit the Background Information portion of the final project, desc.docx
Submit the Background Information portion of the final project, desc.docx
 
Submit Files - Assignment 1 Role of Manager and Impact of Organizati.docx
Submit Files - Assignment 1 Role of Manager and Impact of Organizati.docxSubmit Files - Assignment 1 Role of Manager and Impact of Organizati.docx
Submit Files - Assignment 1 Role of Manager and Impact of Organizati.docx
 
SSChaSimple RegressionSimple Regressionpter C.docx
SSChaSimple RegressionSimple Regressionpter  C.docxSSChaSimple RegressionSimple Regressionpter  C.docx
SSChaSimple RegressionSimple Regressionpter C.docx
 
SRF Journal EntriesreferenceAccount TitlesDebitsCredits3-CType jou.docx
SRF Journal EntriesreferenceAccount TitlesDebitsCredits3-CType jou.docxSRF Journal EntriesreferenceAccount TitlesDebitsCredits3-CType jou.docx
SRF Journal EntriesreferenceAccount TitlesDebitsCredits3-CType jou.docx
 
srcCommissionCalculation.javasrcCommissionCalculation.javaimpo.docx
srcCommissionCalculation.javasrcCommissionCalculation.javaimpo.docxsrcCommissionCalculation.javasrcCommissionCalculation.javaimpo.docx
srcCommissionCalculation.javasrcCommissionCalculation.javaimpo.docx
 
SPSS Assignment Data.savWeek 6, Using Marketing Channel.docx
SPSS Assignment Data.savWeek 6, Using Marketing Channel.docxSPSS Assignment Data.savWeek 6, Using Marketing Channel.docx
SPSS Assignment Data.savWeek 6, Using Marketing Channel.docx
 
SQLServerFilesCars.mdf__MACOSXSQLServerFiles._Cars.mdf.docx
SQLServerFilesCars.mdf__MACOSXSQLServerFiles._Cars.mdf.docxSQLServerFilesCars.mdf__MACOSXSQLServerFiles._Cars.mdf.docx
SQLServerFilesCars.mdf__MACOSXSQLServerFiles._Cars.mdf.docx
 
Square, Inc. is a financial services, merchant services aggregat.docx
Square, Inc. is a financial services, merchant services aggregat.docxSquare, Inc. is a financial services, merchant services aggregat.docx
Square, Inc. is a financial services, merchant services aggregat.docx
 
SQL SQL 2) Add 25 CUSTOMERSs so that you now have 50 total..docx
SQL SQL 2) Add 25 CUSTOMERSs so that you now have 50 total..docxSQL SQL 2) Add 25 CUSTOMERSs so that you now have 50 total..docx
SQL SQL 2) Add 25 CUSTOMERSs so that you now have 50 total..docx
 
SPSS InputStephanie Crookston, Dominique.docx
SPSS InputStephanie Crookston, Dominique.docxSPSS InputStephanie Crookston, Dominique.docx
SPSS InputStephanie Crookston, Dominique.docx
 
Spring  2015  –  MAT  137  –Luedeker       Na.docx
Spring  2015  –  MAT  137  –Luedeker        Na.docxSpring  2015  –  MAT  137  –Luedeker        Na.docx
Spring  2015  –  MAT  137  –Luedeker       Na.docx
 
Springdale Shopping SurveyThe major shopping areas in the com.docx
Springdale Shopping SurveyThe major shopping areas in the com.docxSpringdale Shopping SurveyThe major shopping areas in the com.docx
Springdale Shopping SurveyThe major shopping areas in the com.docx
 
Springfield assignment InstructionFrom the given information, yo.docx
Springfield assignment InstructionFrom the given information, yo.docxSpringfield assignment InstructionFrom the given information, yo.docx
Springfield assignment InstructionFrom the given information, yo.docx
 

Dernier

How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 

Dernier (20)

Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 

Spring 2014 CSCI 111 Final exam of 1 61. (2 points) Fl.docx

  • 1. Spring 2014 CSCI 111 Final exam � of �1 6 1. (2 points) Flip over this test. On the back of this test write your name in the upper, left-hand corner. 2. (2 points) What are the four parts of the compiling process (just give me 4 words, not a paragraph). 3. (4 points) Which of the four steps of the compiling process occurs only once, regardless of the number of source files your application has? 4. (4 points) Write a line of code that causes the preprocessor to generate an error. 5. (4 points) Write a line of code that causes the compiler to generate an error. 6. (5 points) Describe how you could incorrectly compile the joust project to cause the linker to generate an error. 7. (5 points) Given: 1 float* fp; 2 //... 3 float pi; 4 pi=*(314 + fp); Rewrite line 4 using array subscript notation.
  • 2. Spring 2014 CSCI 111 Final exam � of �2 6 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. (14 points) 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)
  • 3. Spring 2014 CSCI 111 Final exam � of �3 6 10. (10 points) 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. (4 points) 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;
  • 4. D) cout << "x" << '%' << 'y' << endl; Spring 2014 CSCI 111 Final exam � of �4 6 12. (16 points) 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 Spring 2014 CSCI 111 Final exam � of �5 6 13. (5 points) Write a for-loop that prints out the numbers
  • 5. between 1 and 100 that are evenly divisible by three. 14. (5 points) Write a while-loop that prints out the numbers between 1 and 100 that are evenly divisible by three. 15. (5 points) Write a do-while-loop that prints out the numbers between 1 and 100 that are evenly divisible by three. Spring 2014 CSCI 111 Final exam � of �6 6 16. (10 points) 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
  • 6. B. Calls the display function CSCI 111, Fall 2013, Final Exam You do NOT have to write complete programs to answer the questions below, unless the question asks explicitly that you do so. 1. (2 points) Write your name on the backside of the last page. 2. (8 points) 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
  • 7. string "This is so easy!" as the argument. Is the function declaration or function definition shown above? 3. (5 points) 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.(5 points) Given:
  • 8. 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.(10 points) Consider the program below in the test.cpp file 1. #include <iostream> 2. using namespace std; 3. int main() 4. {
  • 9. 5. do { 6. cout << “give me an int: “; 7. int i; 8. cin >> i; 9. } while (i < 0 || 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:10:28 error: ’i’ 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.
  • 10. 6.(10 points) Given the statement string* airplane[25]; Describe what is created when this statement is executed. Be explicit in your answer. 7. (10 points) 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.
  • 11. 8. (10 points) Carefully distinguish between the meaning and use of the dot operator “.” and the scope resolution operator “::” 9. (15 points) 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:
  • 12. 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( );
  • 13. aProfit = hyundai.getProfit( ); hyundai = jaguar; 10. (25 points) Write the implementation file (automobile.cpp) for the class contained in automobile.h, which is described in the previous question. CSCI 111, Spring 2013, Final Exam 1. (1 point) Write your name on the backside of the last page. 2. (1 point) Every C++ program begins at the function ____________. 3. (4 point) What is the difference between these 2 include statements. #include <iostream> #include “iostream”
  • 14. 4. (2 point) What is the expected output of the following piece of code? int x = 5.7; int y = 3.2; cout << x-y; 5. (3 point) 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. (4 point) Name the 4 steps that occur when a program is compiled 1. 2. 3. 4. 7. (10 point) Write the implementation file (person.cpp) for the following person.h file. The file must be complete and should compile.
  • 15. #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. (5 point) 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; }
  • 16. 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. (4 point) What is the purpose of a constructor? When does it run? 10. (3 point) Why do you use #ifndef, #define, and #endif in a header file?
  • 17. 11. (2 point) Describe the action of the new operator 12. (3 point) 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. (2 point) What is wrong with the following piece of code? int sampleArray[10]; for (int index = 1; index <= 10; index++) sampleArray[index] = 3*index;