• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 4 out of 34 pages
Exam (elaborations)

CIS 115 A+ complete solution

Document preview thumbnail
Preview 4 out of 34 pages

CIS 115 A+ complete solution

Content preview

Cis 115

1. printTodaysDate();: printTodaysDate
is a function that accepts no parameters and returns no value.
Write a statement that calls printTodaysDate
.
2. void printDottedLine(){
cout<<" .... \n";
}: Write the definition of a function
printDottedLine
, which has no parameters and doesn't return anything.
The function prints a single line consisting of
5
periods (terminated by a new line character) .
3. void printTodaysDate();: Write a statement that declares a prototype for a func-
tion
printTodaysDate
, which has no parameters and doesn't return anything.
4. printErrorDescription(14);: printErrorDescription
is a function that accepts one
int
parameter and returns no value.
Write a statement that calls the function
printErrorDescription
, passing it the value
14
.
5. printLarger(sales1,sales2);: printLarger
is a function that accepts two
int
parameters and returns no value.
Two
int
variables,
sales1
and
sales2
, have already been declared and initialized.
Write a
statement
that calls


, Cis 115

printLarger
, passing it
sales1
and
sales2
.
6. void printLarger(int one,int two){
if(one>two)
cout<<one<<endl;
else
cout<<two<<endl;
}: Write the definition of a function
printLarger
, which has two
int
parameters and returns nothing. The function prints the larger value of the two
parameters on a single line by itself. (For purposes of this exercise, the "larger"
means "not the smaller".)
7. int add(int,int);: Write a statement that declares a prototype for a function named
add
which has two
int
parameters and returns an
int
.
8. eurasiaSales=add(asiaSales,euroSales);: add
is a function that accepts two
int
arguments and returns their sum.
Two
int
variables,
euroSales
and
asiaSales
, have already been declared and initialized. Another
int
variable,
eurasiaSales


, Cis 115

, has already been declared.
Write a statement that calls the
add
function to compute the sum of
euroSales
and
asiaSales
and store this value in
eurasiaSales
.
9. int oneLess(int amount){
return amount-1;
}: Write the definition of a function named
oneLess
, which receives an
int
argument and returns an
int
that is one less than the value of the argument. So if the argument's value is
7
, the function returns the value
6
. If the argument's value happens to be
44
, the functions returns the value
43
10. int half(int amount){
return amount/2;

}: Write the
definition
of a function named
half
, which receives an integer argument and returns an integer that is
half
the value of the parameter. (Use integer division!)
So if the argument's value is
7
, the function returns the value


, Cis 115

3
.
If the argument's value happens to be
44
, the functions returns the value
22
.
11. bool isPositive(int num){
if(num>0){
return true;
}
else{
return false;

}
}: Write the definition of a function named isPositive, that receives an integer argu-
ment and returns true if the argument is positive, and false otherwise.

So, if the argument's value is 7 or 803 or 141 the function returns true.

But if the argument's value is -22 or -57, or 0, the function returns false
12. int counter(){
static int x=0;
return x++;
}: Write the definition of a function named
counter
that receives no parameters and returns
0
the first time it is invoked, returns
1
the next time it is invoked, then
2
,
3
and so on.
13. double timeOnHighway(double mileEndingPoint,
double mileStartingPoint=0.0, double speed=55.0){
return (mileEndingPoint-mileStartingPoint)/speed;
}: Write the definition of a function named

Document information

Uploaded on
August 12, 2024
Number of pages
34
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$3.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
sylvianthiwa
2.5
(2)
Sold
7
Followers
6
Items
574
Last sold
6 months ago




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions