C109s08t1 - CSE 109 Test 1 Friday 22 February 2008 >SUGGESTED ANSWERS< 1 Write the output that occurs when the following program is run#include

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE 109 Test 1 Friday 22 February 2008 >>>>>>>>>>>>>>>>>>>>>>>>>>>SUGGESTED ANSWERS<<<<<<<<<<<<<<<<<<<<<<<<<<< 1. Write the output that occurs when the following program is run. #include <iostream> using namespace std; int temp; temp=a; a=b; b=temp; b+=2; c+=a; } *a+=2; b=a; *b+=3; } int *temp; temp=a; a=b; b=temp; c=a; } int main(){ int u=2, v=3, w=4, *r, *s, *t; x(u,v,w); cout<<u<<" "<<v<<" "<<w<<endl; <<<<<<<< 2 4 7 u=2; x(u,u,u); cout<<u<<endl; <<<<<<<< 6 s=&u; t=&v; u=2; v=3; y(s,t); cout<<u<<" "<<v<<" "<<*s<<" "<<*t<<endl; <<<<<<<< 7 3 7 7 s=&u; u=2; y(s,s); cout<<u<<" "<<*s<<endl; <<<<<<<< 7 7 u=2; v=3; w=4; r=&u; s=&v; t=&w; z(r,s,t); cout<<*r<<" "<<*s<<" "<<*t<<endl; <<<<<<<< 2 2 3 } 2. Write a function select() that reads text from an input stream and writes to the console only those characters that are in a given string. For example, the code istream f("input.dat"); select(f,"12345.!"); would display on the screen only those characters in the file 'input.dat' that
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/09/2008 for the course CSE 109 taught by Professor Kay during the Spring '08 term at Lehigh University .

Page1 / 3

C109s08t1 - CSE 109 Test 1 Friday 22 February 2008 >SUGGESTED ANSWERS< 1 Write the output that occurs when the following program is run#include

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online