Professional Documents
Culture Documents
Topics:
• Review HW and C++ Compiler Installation Video part 1 of 4
• Software Development Life Cycle (SDLC) Video part 2 of 4
• Problem-solving methodology
• Program Structure
• Constants and Variables
• Assignment Statements
• Input and Output Video part 3 of 4
• Computer Literacy Questions and Answers Video part 4 of 4
• HW #1
© R. Avanzato 1
Review HW
• Any problems with Canvas discussion board? (if so,
contact instructor by email).
• Any questions?
NOTE: This course has been transitioned to the Canvas
learning management system – ignore any references to
the Angel course management system
© R. Avanzato 2
Review Questions
1) Software instructions and data are stored in
(a) Clock
(b) CPU
(c) Memory
(d) Keyboard
2) Source code is
a) Output of compiler
b) Set of machine instructions
c) Set of programming language instructions
d) Data stored in memory
© R. Avanzato 3
Review Questions
© R. Avanzato 4
Review Questions
1. What is the difference between HTML and C/C++
programming language?
Libraries
Programmer User
• When you (or the user) run (execute) your C program, you are really
executing the .exe. file.
• A source program needs to be re-compiled every time you make a
change to the source code. That is, you must create a new executable
file (.exe) every time you make a change.
• The executable file can be executed (run) many times.
• When you sell a program (ex. game), you distribute the executable file,
not the source code. © R. Avanzato 6
Is this C program useful? - Discuss
#include <iostream>
using namespace std;
int main ()
{
double x = 10, y = 25, sum;
sum = x + y;
cout << "Sum = " << sum;
return 0;
}
© R. Avanzato 7
What is wrong with this C program?
#include <iostream>
using namespace std;
int main ()
{
double x , y, sum;
sum = x + y;
cout << "Sum = " << sum;
return 0;
}
© R. Avanzato 8
CMPSC 201C
Programming for Engineers
Lecture Set #2
Video part 2 of 4
R.Avanzato © 2017
Topics:
• Review HW and C++ Compiler Installation
• Software Development Life Cycle (SDLC) Video part 2 of 4
• Problem-solving methodology
• Program Structure
• Constants and Variables
• Assignment Statements
• Input and Output
• Computer Literacy Questions and Answers
• HW #1
© R. Avanzato 9
Software Development Life Cycle
(SDLC)
• Discuss the software crisis in industry today.
• Software development is extremely expensive.
• Many software projects are late, more expensive than planned, do
not work well, etc.
• Small s/w projects (~100 to 5000 lines of code)
• Medium s/w projects (~5000 to 50,000 lines of code
• Large s/w projects (~50,000 to 10 million+ lines of code)
• Object-oriented programming
© R. Avanzato 13
2 versions of preprocessor directives
<< or >>
• Variables can be of any length, but only first 31 characters are used.
• Each type (int, float, double, etc) has a unique maximum value
(total number of bits)
/* xxxxxxxxx */
Note: You cannot "nest" comments. That is, you cannot place comments
within comments (the C++ compiler gets confused and complains)
Lecture Set #2
Video part 3 of 4
R.Avanzato © 2017
Topics:
• Review HW and C++ Compiler Installation
• Software Development Life Cycle (SDLC)
• Problem-solving methodology
• Program Structure
• Constants and Variables
• Assignment Statements
• Input and Output Video part 3 of 4
• Computer Literacy Questions and Answers
• HW #1
© R. Avanzato 19
User Input Example (lab)
#include <iostream>
using namespace std;
int main ()
{
double x, y, sum;
cout << “Enter a number”;
cin >> x;
cout << “Enter another number”;
cin >> y;
sum = x + y;
cout << "Sum = " << sum;
return 0;
}
// modify above pgm to also calculate the average
© R. Avanzato 20
Conversion Program (lab)
// Program converts inches into feet
#include <iostream>
using namespace std;
int main ()
{
double inches, feet;
cout << “Enter number of inches”;
cin >> inches;
feet = inches / 12.0;
cout << inches << " inches = " << feet << “ feet”;
return 0;
}
© R. Avanzato 21
Conversion Program (lab) - version 2
// Program converts inches into feet
#include <iostream>
using namespace std;
int main ()
{
double inches, feet;
Defining
constants using const double INPERFT = 12.0;
‘const’ is cout << “Enter number of inches”;
considered cin >> inches;
good feet = inches / INPERFT;
programming cout << inches << " inches = " << feet << " feet";
style
return 0;
}
© R. Avanzato 22
Conversion Program (lab) - version 3
© R. Avanzato 24
File sizes
• What is the size (#of bytes) of a typical .cpp file? (Check
properties)
• Is the .cpp file a text file?
• Is the .cpp file an ASCII file?
• What is the difference between a text file and a MS word doc
file?
• What is the size of a typical .exe file?
• How do you execute a .exe file? (not using the Dev-C or other
editor)
• Lab exercise: Open Notepad and enter your first name. Save
file and examine properties to find file size in bytes. What is
relationship between a character and a byte?
Lecture Set #2
Video part 4 of 4
R.Avanzato © 2017
Topics:
• Review HW and C++ Compiler Installation
• Software Development Life Cycle (SDLC)
• Problem-solving methodology
• Program Structure
• Constants and Variables
• Assignment Statements
• Input and Output
• HW #1 Video part 4 of 4
• Computer Literacy Questions and Answers
© R. Avanzato 26
Homework #1 (see due date)
Write and test 2 complete C++ programs:
#1(convert miles to km), #2 (convert miles per hour to feet per second)
In each program , the user will be prompted for an input value; display all units.
Total of 2 problems. Programs should be clear and user-friendly.
C++ for the Absolute Beginner 2nd edition by Mark Lee (PSU Safari)
Chapter 1 and 2
(some minor notation differences)
Prata textbook also useful but uses older style of display (printf instead of cout).
However, concepts are the same. See Amazon for purchase of ebook.
Etter textbook (see syllabus for reference); available on Amazon $80 (ebook)
Ask questions.