Practice using g++, nano, and weblab.uni.edu in StudioIT 1 ITT 134 lab classroom. hello.cpp file example ----- #include <iostream> using namespace std; int main() { String name; cout << "What is your name? "; cin >> name; cout << "Hello " << name << endl; } -------- area.cpp example developed in class -------- radius of a circle is the input area of a circle is the output [jacobson@weblab ~]$ more area.cpp #include <iostream> using namespace std; int main() { double radius; double area; cout << "Please enter the radius of your circle: "; cin >> radius; area = 3.14159 * radius * radius; cout << "Area is " << area << endl; }
See the email notes about textbook: emailTextbook.txt.
// Day #1 example - Monday, January 11th, 2015 #include <iostream> using namespace std; int main() { cout << "Hello World!" << endl; return 0; }
[jacobson@weblab ~]$ more day1.cpp Program was created and stored in a file named day1.cpp // Day #1 example nano day1.cpp was the command #include <iostream> used to edit using namespace std; the program more day1.cpp int main() is used to display { the file day1.cpp cout << "Hello World!" << endl; on the screen return 0; } [jacobson@weblab ~]$ [jacobson@weblab ~]$ g++ day1.cpp g++ is the name of the compiler [jacobson@weblab ~]$ [jacobson@weblab ~]$ ./a.out ./a.out is the name of the executable Hello World! program, actually just
I - What is the input for the problem? What input is needed? What is given? What information do you need to have in order to produce a solution or an answer that will be the exciting output? O - What is the desired output? What is the result that is needed? What will be the result of running the program? P - How do you get from I to O? What processing steps are needed to transform, manipulate, analyze the input to obtain the desired output? The focus is on HOW to get from I to O. After you develop the understanding of I and O and have developed the algorithm that develops the P for how to go from Input to Output in a series of well described well understood steps, then and only then do you start to write the C++ code. Resist the urge to code. We will cover this in more depth throughout the class as it is the key to programming and problem solving.