CSCE 150A Laboratory Assignment 6 - Spring 2009, Assignments of Computer Science

Information about csce 150a lab assignment 6 from spring 2009. The assignment includes two problems. The first problem involves practicing with pointers and filling in the values of variables after code execution. The second problem requires filling in the main method to run a program that asks for an amount of money and prints the value in several different currencies, the amount of snacks that can be bought, and how much to tip the gta using output parameters.

Typology: Assignments

Pre 2010

Uploaded on 08/30/2009

koofers-user-mot
koofers-user-mot 🇺🇸

5

(2)

9 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSCE 150A - Problem Solving Using Computers Laboratory - Spring 2009
Lab Assignment 6 - 02/18/2009
Name:
Section: 8:00 11:00 12:30 6:30
Problem 1: Practice with Pointers
The following table has columns for five int variables, giving their addresses and initial values. In each
blank row, fill in the values of the variables after the code statement has executed.
Variable Name: abcde
Variable Address: 104 108 112 116 120
Variable Value: 20 4 104 10 1
*c = b * d;
e = &d-b;
a = *c + **e;
Bonus: b = b***e**c*d;
Problem 2: Using Multiple Output Parameters
Download currency.c from the course web site. Fill in the main method to run a program that asks for
an amount of money, and then prints the value in several different currencies, the amount of snacks you could
buy, and how much you should tip your GTA. You will use the following methods with output parameters
in order to calculate the values:
void currencies(double usdollars, double* euros, double* pounds, double* yen) places into
*euros,*pounds, and *yen the value of usdollars after exchange.
void snacks(double usdollars, int* snickers, int* ice cream cones, int* sodas) buys as
many Snickers, ice cream cones, and sodas as you can afford with usdollars.
void gtaTip(double usdollars, double* tip, double* money left) places the amount you should
tip your GTA into tip and the remaining amount into money left.
When you are done, show the instructor. There is no grading script this week, so you have freedom with
your output! Make sure the values returned by the methods are printed to the screen.
Hints: Keep all of your code in the main method, but call the defined methods to get the values.

Partial preview of the text

Download CSCE 150A Laboratory Assignment 6 - Spring 2009 and more Assignments Computer Science in PDF only on Docsity!

CSCE 150A - Problem Solving Using Computers Laboratory - Spring 2009

Lab Assignment 6 - 02/18/

Name:

Section: 8:00 11:00 12:30 6:

Problem 1: Practice with Pointers

The following table has columns for five int variables, giving their addresses and initial values. In each blank row, fill in the values of the variables after the code statement has executed.

Variable Name: a b c d e

Variable Address: 104 108 112 116 120

Variable Value: 20 4 104 10 1

*c = b * d;

e = &d-b;

a = *c + **e;

Bonus: b = becd;

Problem 2: Using Multiple Output Parameters

Download currency.c from the course web site. Fill in the main method to run a program that asks for an amount of money, and then prints the value in several different currencies, the amount of snacks you could buy, and how much you should tip your GTA. You will use the following methods with output parameters in order to calculate the values:

  • void currencies(double usdollars, double* euros, double* pounds, double* yen) places into *euros, *pounds, and *yen the value of usdollars after exchange.
  • void snacks(double usdollars, int* snickers, int* ice cream cones, int* sodas) buys as many Snickers, ice cream cones, and sodas as you can afford with usdollars.
  • void gtaTip(double usdollars, double* tip, double* money left) places the amount you should tip your GTA into tip and the remaining amount into money left.

When you are done, show the instructor. There is no grading script this week, so you have freedom with your output! Make sure the values returned by the methods are printed to the screen.

Hints: Keep all of your code in the main method, but call the defined methods to get the values.