CSE202Lab2

CSE202Lab2 - << b...

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

View Full Document Right Arrow Icon
CSE 202 Lab 2 NOTE: No need to submit anything electronically. 1. From the terminal, type in: cd mkdir lab2 cd lab2 The first command ensures that you are in your home directory. The second creates a new directory, called lab2, and the third brings you into lab2/ as your working directory . You will repeat these steps for future labs (lab3, lab4, etc). It may be worth noting that you can combine these three commands into one line: cd; mkdir lab2; cd lab2 1. Use emacs and create a new file, mod_example.cpp. Recall that to do this, type the following in the terminal: emacs mod_example.cpp & Type in the following program exactly as shown. #include <iostream> using namespace std; int main() { int a; double b = 4 * (33 + 2) / 3; a = ((54 + 3) - 2) % 2; cout << "The value of the expression ((54 + 3) - 2) % 2 is " << a << "\n"; cout << "The value of the expression 4 * (33 + 2) / 3 is "
Background image of page 1

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

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

Unformatted text preview: &lt;&lt; b &lt;&lt; &quot;\n&quot;; return 0; } Save it, and then compile it. Recall that to save in emacs, use this sequence: Control + X then Control + S and to compile a source file, from the terminal, type: g++ mod_example.cpp -o binary_name Above, you can name binary_name anything you want (EXCEPT, of course, the name of the source file!), but it is suggested that you give it a mnemonic name, such that it is not ambiguous or confusing to yourself or anyone that might be writing a program. In Windows, for instance, binary names end in &quot;.exe&quot; to distinguish that they are executable files. After running your program, answer the following questions: a. What is the output? Give explanations why you received this output. That is, evaluate the expressions mathematically and verify the results. b. We declared the variable a as an int type. Why is that?...
View Full Document

This note was uploaded on 10/18/2009 for the course CSE 201 taught by Professor All during the Spring '09 term at Ohio State.

Page1 / 2

CSE202Lab2 - &amp;amp;lt;&amp;amp;lt; b...

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