• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 4 fuera de 34 páginas
Examen

CIS 115 A+ complete solution

Document preview thumbnail
Vista previa 4 fuera de 34 páginas

CIS 115 A+ complete solution

Vista previa del contenido

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

Información del documento

Subido en
12 de agosto de 2024
Número de páginas
34
Escrito en
2024/2025
Tipo
Examen
Contiene
Preguntas y respuestas
$3.49

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
sylvianthiwa
2.5
(2)
Vendido
7
Seguidores
6
Artículos
574
Última venta
6 meses hace




Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes