Exam 1- 2010

State whether each snippet of code is valid c meaning

Info iconThis preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: t; endl; (e) int a = 2; if (a > 0) { a = -1 * a; } else if (a < 0) { a = 3; } cout << a << endl; (f) for (int i=3; i > 0; i--) { cout << i << " "; } CS 115 Exam 1, Spring 2010 Page 3 of 7 Problem 2: 16 points. State whether each snippet of code is valid C++, meaning that it will compile. If it is valid, write “valid.” If it is invalid, write “invalid” and make a small change so that it will compile. (a) int a; cin >> a >> endl; cout << a << endl; (b) int i = 5; do while { cout << i << endl; } (i > 7); (c) int q = 2; cout << (2*q)++ <<...
View Full Document

This note was uploaded on 02/08/2014 for the course CS 115 taught by Professor Staff during the Fall '08 term at Sonoma.

Ask a homework question - tutors are online