{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# HW_2 - CS 31 INTRODUCTION TO COMPUTER SCIENCE I Computer...

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

CS 31: INTRODUCTION TO COMPUTER SCIENCE I Computer Science Department University of California, Los Angeles Dr. John A. Rohr February 3, 2010 HOMEWORK 2 Objective : Practice vector and matrix input and display. Background : A vector of dimension m consists of m elements in consecutive order. A square matrix of dimension n consists of n 2 elements arranged as n rows by n columns. A vector can be input given the dimension of the vector and the elements of the vector. A square matrix can be input given the dimension of the vector and the elements of the vector. Assignment : Write two programs to input and display vectors and matrices. 1. Write a C++ program that will prompt for and read a dimension n , read element values and store them in a vector of dimension n , and display the vector vertically. Support vectors of dimension 1 to 10. Display each vector element on a separate line using default width and exactly four decimal places for each value displayed. 2. Write a C++ program that will prompt for and read a dimension m , read element values and store them in a square matrix of dimension

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 2

HW_2 - CS 31 INTRODUCTION TO COMPUTER SCIENCE I Computer...

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

View Full Document
Ask a homework question - tutors are online