44
1/44 Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q&A Conclusion References Files Vita CSC-201 - Computer Science I Lecture #1: Introduction and Overview Chapters 1 and 2 Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge August 29, 2016 at 9:33am August 29, 2016 at 9:33am August 29, 2016 at 9:33am August 29, 2016 at 9:33am August 29, 2016 at 9:33am August 29, 2016 at 9:33am August 29, 2016 at 9:33am August 29, 2016 at 9:33am August 29, 2016 at 9:33am August 29, 2016 at 9:33am August 29, 2016 at 9:33am August 29, 2016 at 9:33am August 29, 2016 at 9:33am August 29, 2016 at 9:33am August 29, 2016 at 9:33am August 29, 2016 at 9:33am August 29, 2016 at 9:33am August 29, 2016 at 9:33am August 29, 2016 at 9:33am August 29, 2016 at 9:33am August 29, 2016 at 9:33am

CSC-201 - Computer Science I Lecture #1: Introduction and

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

CSC-201 - Computer Science I Lecture #1: Introduction and Overview Chapters 1 and 21/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
CSC-201 - Computer Science I Lecture #1: Introduction and Overview
Chapters 1 and 2
Dr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck Cartledge
August 29, 2016 at 9:33amAugust 29, 2016 at 9:33amAugust 29, 2016 at 9:33amAugust 29, 2016 at 9:33amAugust 29, 2016 at 9:33amAugust 29, 2016 at 9:33amAugust 29, 2016 at 9:33amAugust 29, 2016 at 9:33amAugust 29, 2016 at 9:33amAugust 29, 2016 at 9:33amAugust 29, 2016 at 9:33amAugust 29, 2016 at 9:33amAugust 29, 2016 at 9:33amAugust 29, 2016 at 9:33amAugust 29, 2016 at 9:33amAugust 29, 2016 at 9:33amAugust 29, 2016 at 9:33amAugust 29, 2016 at 9:33amAugust 29, 2016 at 9:33amAugust 29, 2016 at 9:33amAugust 29, 2016 at 9:33am
2/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Table of contents I 1 Schedule
2 Overview
3/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Schedule for the semester
Wk. Date Topic Wk. Date Topic 1 08/22 Chap 1 – 2 9 10/17 Chap 10 2 08/29 Chap 3 – 4 10 10/31 Chap 10 – 11 3 09/05 Chap 5 11 10/31 Chap 10 – 11 4 09/12 Test – Chap 6 12 11/07 Test– Chap 14 5 09/19 Chap 7 13 11/14 Chap 14 6 09/26 Chap 8 14 11/28 Chap 18 7 10/03 Chap 9 15 12/05 Chap 18 8 10/10 Test – Chap 10 16 12/12 Exam
4/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Why are we here?
1 The course is a requirement
2 The language is common
3 The language has interesting features
4 Understanding the language helps with other languages
5/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Why are we here?
6/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Why are we here?
Computer languages are not static.
Languages are created and evolve to meet new needs. Languages have some underlying common factors, because they all run on computers.
Image from [1].
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Why are we here?
Comparing various known languages
Each language is reflection of the current state of the art in solving a particular type of problem. You can expect to learn and use many different languages over the course of your career, and supporting different programming paradigms,
http://hyperpolyglot.org/
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Why are we here?
Hammer and nails . . .
“. . . it is tempting, if the only tool you have is a hammer, to treat everything as if it were a nail.”
Abraham H. Maslow [4]
9/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Why are we here?
The Socratic method includes the use of systematic questioning, inductive reasoning, universal definitions, and a disavowal of knowledge.
James C. Overholser [5]
10/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Chapter 1
What is computer programming?
Computer programming is creating a series of steps for a computer to execute to achieve a result.
Image from [8].
11/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Chapter 1
An algorithm is a series of language agnostic steps
Algorithms say what needs to get done, not how. Algorithms can be time, or memory efficient. Good ones are both.
Image from [2].
12/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Chapter 1
There are lots of steps in the process:
1 A human has to understand the problem
2 A human selects the appropriate algorithm
3 A human selects the appropriate language
4 A human writes the necessary steps in the
language (source code)
5 A compiler translates the source code into object code
6 The computer loads the object code
7 The computer starts program execution at a “well known” spot in the object code
Only the last two steps are fast.
13/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Chapter 1
2 We’ll may, or may not use an algorithm
3 We’ll use C++
4 We’ll use the CodeBlock IDE to edit, compile, and run our program
5 We’ll learn new parts of the language
14/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Chapter 1
Software development life cycle (SDLC)
There are many different SDLC models. For our purposes, we’ll focus on:
1 Problem solving (requirements and design)
2 Implementation (construction and verification)
3 Maintenance
15/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Chapter 1
Analyze the problem and specify what the solution must do
Develop an algorithm to solve the problem
Verify that your solution really solves the problem
16/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Chapter 1
Implementation phase
Testing your program to see if it produces correct results
Debugging your program to identify and correct errors
17/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Chapter 1
Maintenance
Use and modify the program to meet changing requirements or correct errors that show up in using it
Maintenance begins when your program is put into use and accounts for the majority of effort on most programs
Wholly rewriting program with a clear design sometimes a useful alternative to modifying the existing program to meet changing requirements
18/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Chapter 1
Relay switches are part of early (and some current) computers
Grace Hopper found a moth stuck between the relay contacts
Bug was removed from the computer and the program worked
Image from [10].
19/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Chapter 1
A way to input and output data
A central processing unit (CPU)
Memory (volatile and non-volatile)
A language the CPU understands
The language is composed of binary values Topics of CSC-205 and CSC-215.
Other computer types have similar components.
20/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Chapter 2
Elements of C++ programs
Every program must have a main function that returns an integer.
Every identifier is composed of letters, numbers, or underscores, and must start with a letter or underscore.
Identifiers are case sensitive
Open and closing curly braces define a context, and may be nested.
There are a limited number of built-in data types.
Assignments to identifiers are identifier = expression;
21/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Chapter 2
22/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Chapter 2
How to get values in and out
C++ requires a preprocessor directive to include the ability to input and output values.
#include<iostream>
std::cout << ’’Hello world.’’ << std::endl;
std::cout << thisIsA_variable << anotherVariable << std::endl;
std::cin >> anInt;
std::cin >> aString;
The “std::” refers to a namespace. We’ll talk about that later.
23/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Chapter 2
Built-in data types.
All other types are user-defined and brought in via preprocessor directives.
signed is default, unsigned must be specified
short is at least 16 bits wide
long is at least 32 bits
long long is at least 64 bits
Image from [7].
24/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Chapter 2
Same image.
25/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Chapter 2
Additional data refinements
The choices made by each implementation about the sizes of the fundamental types are collectively known as data model. Four data models found wide acceptance:
32 bit systems:
LP32 or 2/4/4 (int is 16-bit, long and pointer are 32-bit) (Win16 API) ILP32 or 4/4/4 (int, long, and pointer are 32-bit) (Win32 API, Unix and Unix-like systems)
64 bit systems:
LLP64 or 4/4/8 (int and long are 32-bit, pointer is 64-bit) (Win64 API) LP64 or 4/8/8 (int is 32-bit, long and pointer are 64-bit) (Unix and Unix-like systems)
26/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Break time.
27/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
CodeLab main screen
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Same image.
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
CodeBlock main screen
30/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Same image.
31/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Open a file for editing
We will be using standalone files. Not projects. Most files will be attached to a presentation.
32/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Same image.
33/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
A file will appear in a tab
Most of our coding and exploration will be using only a few files.
34/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Same image.
35/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Compile and run a file with F9
Feed back from the compiler will appear in the “Build messages” tab
36/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Same image.
37/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Practice exercises
1 firstone.cpp
2 error.cpp
3 leapYear.cpp
4 dinner.cpp
5 greet.cpp
38/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Q & A time.
“’The Answer to the Great Question . . . Of Life, the Universe and Everything . . . is . . . forty-two,’ said Deep Thought, with infinite majesty and calm.” Douglas Adams, The Hitchhiker’s Guide to the Galaxy
39/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
What have we covered?
Why are we here. Where we’re going. How we’ll get there. Basic ideas of computer programming. Hands on programming with CodeLab and CodeBlock.
Next time Chapters 3 & 4.
40/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
References I
evolution-of-computer-languages-infographic, 2011.
[2] Owen Astrachan, Bubble sort: an archaeological algorithmic analysis, ACM SIGCSE Bulletin, vol. 35, ACM, 2003, pp. 1–5.
[3] Eric Johnson, Secure software development lifecycle overview, https:
//software-security.sans.org/blog/2015/04/07/
secure-software-development-lifecycle-overview, 2015.
[4] Abraham H. Maslow, The psychology of science, Henry Regency, 1966.
References II
[5] James C. Overholser, Elements of the socratic method: V. self-improvement, Psychotherapy: Theory, Research, Practice, Training 33 (1996), no. 4, 549.
[6] Sylvia Sorkin, Programming and problem solving with c++, Teacher Resource Jones and Barlett Learning, 2014.
[7] C++ Staff, Fundamental types, http://en.cppreference.com/w/cpp/language/types, 2016.
[8] Derivativesinvesting Staff, Qc 7 tools, http://www.derivativesinvesting.net/article/
277260716/qc-7-tools/, 2016.
References III
happiness/abraham-maslow/, 2016.
Files of interest
// Program Area calculates the area of a square.     
// The user is prompted to enter the number of inches on each
// side. Note that “endl” in line 7 ends in the letter “l”, not
// the number one.
        << endl;
        << endl;
        << endl;
chessboard.cpp
// Chessboard program
// This program prints a chessboard pattern that is built up from
// basic strings of white and black characters.
//******************************************************************
const string BLACK = "********";  // Define a line of a black square
const string WHITE = "        ";  // Define a line of a white square
int main ()
  
  whiteRow = WHITE + BLACK + WHITE + BLACK +
             WHITE + BLACK + WHITE + BLACK;
  blackRow = BLACK + WHITE + BLACK + WHITE +
             BLACK + WHITE + BLACK + WHITE; 
dinner2.cpp
#include <iostream>
#include <string>
const string VEGGIE = "Carrots with lemon butter";
const string STARCH = "Mashed potatoes";
const string DESSERT = "Apple pie";
int main ()
        + STARCH;
  cout  << "Dessert: "  << DESSERT;
dinner.cpp
const SALAD = "Green Salad";                          // 2
const MEAT = "Chicken Marsala";                       // 3
const VEGGIE = 'Carrots with lemon butter';           // 4
STARCH = "Mashed potatoes"                            // 5
        + STARCH;                                     // 10
  cout  << "Dessert: "  << DESSERT;                   // 12
error.cpp
#include <iostream>
  cout <<"how a missing semicolon can "
  cout <<"cause a problem." <<endl;
  cout <<"*********************" <<endl;
  return 0;
firstone.cpp
#include <iostream>
greet2.cpp
#include <iostream>
#include <string>
greet.cpp
#_________
#_________
leapYear.cpp
// This program inputs a year and prints whether the year
// is a leap year or not
//***********************************************************
 
 
 
  cout << "Enter a year AD, for example, 1997."
       << endl;              // Prompt for input
  cin >> year;               // Read year
    cout << year << " is a leap year."  << endl;
  else
 
}
 
//**********************************************************
 
// IsLeapYear returns true if year is a leap year and
// false otherwise. 
  if (year % 4 != 0)    // Is year not divisible by 4?
    return false;       // If so, can't be a leap year
                        // Must be divisible by 4 at this point
  if (year % 100 != 0)  // Is year not a multiple of 100?
    return true;        // If so, is a leap year
                        // Must be divisible by 100 at this point
  if (year % 400 != 0)  // Is year not a multiple of 400?
    return false;       // If so, then is not a leap year
                        // Must be divisible by 400 at this point
  return true;          // Is a leap year
}
rain.cpp
// Program Rain calculates the average rainfall over a period 
// of days.  The number of days and the rain statistics are in 
// file Rain.in.
// Function returns the total inches of rain
// Pre:  File rainFile has been opened; numberOfDays is the 
//       first value on the file, followed by numberOfDays 
//       real values representing inches of rain.
int main()
  int numberOfDays;        // Number of days in calculation
  ifstream  rainFile;      // Data file
  else
         << numberOfDays; 
         << average  << endl;
{
  int counter;          // Loop control variable
  float totalRain = 0.0;
5 2.3 0.0 0.1 1.1 2.1
"Nell Drake and Chip Weems"
rhyme.cpp
#include <iostream>
#include <string>
const string VERB3 = "washed ";
int main()
    "the water spout";
    "the spider out";
    "all the rain";
    "the spout again";
shell.cpp
wrap.cpp
// Program Wrap writes out the contents of a sandwich wrap.
#include <iostream>
#include <string>
  wrap = filling + " in " + WRAP + '.';
  cout  << "Filling : "  << filling  << endl;
  cout  << "Wrap : " << wrap  << endl;
Name: ________________________________________
Official Curriculum Guide
The Associate of Science (A.S.) degree in Science with a Specialization in Computer Science is designed for students who plan to transfer to a four-year college or university to pursue a baccalaureate degree in computer science. This degree program also meets the needs of students seeking teacher certification in secondary mathematics or computer science.
Computer Science courses required for the Computer Science specialization are offered at the Virginia Beach and Chesapeake campuses.
Associate of Science: Science (Computer Science)(880-01)
Course No. Course Title Credits Prerequisites When Taken Grade
SEMESTER 1 Co-Requisites
___________NoneCSC 110 ( )Introduction to Computing 3 Placement into MTH 173
___________NoneENG 111 ( )College Composition I 3 Qualifying Placement Test score, ENF 1, ENF 2 or equivalent
___________NoneMTH 173 ( )Calculus with Analytic Geometry I
5 Qualifying Placement Test score, MTH 164 or MTH 166
___________NoneSDV 100 ( )College Success Skills (or SDV 101)
1 None
Semester Total 15
SEMESTER 2 Co-Requisites
___________NoneCSC 201 ( )Computer Science I 4 CSC 110
___________NoneENG 112 ( )College Composition II 3 ENG 111 or equivalent and ability to use word processing software
___________NoneMTH 174 ( )Calculus with Analytic Geometry II
4 MTH 173 or equivalent
______________________ ( )History Elective 2 3 Placement into ENG 111
Semester Total 14
SEMESTER 3 Co-Requisites
08/22/2016
Tidewater Community College Page 1 of 2 Catalog 2016 - 2017
Course No. Course Title Credits Prerequisites When Taken Grade
SEMESTER 3 Co-Requisites
___________NoneCSC 210 ( )Programming With C++ 4 CSC 201 or EGR 125
______________________ ( )Health/Physical Education Elective 4
______________________ ( )Social Science Elective 1 3
Semester Total 16
SEMESTER 4 Co-Requisites
3 CSC 205
Semester Total 16
Total Minimum Credits 61 1
Eligible courses are listed on page 35 in the 2016-2017 catalog. See your academic advisor or counselor to choose the appropriate course(s). Sequenced lab courses are required in natural and physical sciences, and ENV 121-122 is not an acceptable sequence.
2 Students may select any of the following courses to meet this requirement: HIS 101, 102, 111, 112, 121, or 122.
3 The "Approved Electives" may be satisfied with any mathematics, natural science, social science, humanities, or foreign language electives listed on page 35 of the 2016-2017 catalog. Additional course options are provided on the advising transcript in the Student Information System and/or through consultation with a counselor or academic advisor.
4 Students may select any of the following courses to meet this requirement: DIT 121, 125; HLT 100, 105, 106, 110, 116, 121, 130, 138, 141, 150, 160, 200, 204, 215; PED (any activity course).
08/22/2016
Tidewater Community College Page 2 of 2 Catalog 2016 - 2017
"TCC Staff"
44/44
Schedule Overview Chapters 1 & 2 Break CodeLab CodeBlock Hands on Q & A Conclusion References Files Vita
Who am I?
A perennial student
1st computer: 1970, donated ICBM guidance computer, machine code, paper/mylar tape, and drum memory
Interests: autonomic systems, real–time applications, distributed processing, long-term preservation of digital data, Big Data
Schedule
Overview