Welcome%20to%20IIT%20and%20cs105! - PowerPoint PPT Presentation

About This Presentation
Title:

Welcome%20to%20IIT%20and%20cs105!

Description:

Welcome to IIT and cs105! * – PowerPoint PPT presentation

Number of Views:167
Avg rating:3.0/5.0
Slides: 74
Provided by: Preferr507
Learn more at: http://www.cs.iit.edu
Category:

less

Transcript and Presenter's Notes

Title: Welcome%20to%20IIT%20and%20cs105!


1
Welcome to IIT and cs105!
2
CS 105 - Sec. 02 Summer 2015
  • George Koutsogiannakis office 112 SB
  • 312-567-5288
  • koutsogiannakis_at_iit.edu
  • Best way to communicate with me outside of class
    is via email or
  • In my office after class 12 noon-100p.m. T
    Th.
  • Course web site
  • www.cs.iit.edu/cs105

3
  • Lecture/Lab T,R
  • 500 P.M. 800 P.M. SB 108

4
CS Intro Courses
  • CS 105 1-Semester Requiring Little or No
    Previous Programming Experience, Programming in
    C
  • The course covers programming fundamentals.
    Practice exercises are assigned.

5
CS 105 Required Textbook and Lab Manual
  • CProgramming From Problem Analysis to Program
    Design By D.S. Malik,
  • 5th (red) Edition
  • You can use other editions but note that the
    schedule of assignments is based on the 5th
    edition (page numbers differ from edition to
    edition)

6
CS 105 - Quizzes/Exams Grading
  • 2 Quizzes Each 5 of Grade
  • 2 Exams
  • Exam I - Lecture Exam - 10
  • Exam II - Lecture Exam - 25
  • Final Exam - 35
  • Labs - 20
  • Must Take Final to Pass Course

7
CS105 Labs
  • 11 Labs Assigned consist of
  • Reading Assignment, and Lab Exercises from
    Textbook.
  • Programming Exercises (Located at End of Each
    Chapter in Textbook)
  • Labs Due on specific dates as mentioned on the
    web site.
  • Must be present in order to receive credit!
    Points are subtracted if late for lab session.
  • Show answers to instructor to receive credit.
  • Grades are posted on Blackboard.
  • Labs 0-9 1.8 points each
  • Lab 10 2 points
  • Total 20 points towards your final grade.

8
Lab Grading procedure
  1. Start lab on assigned date in class when the
    instructor finishes the lecture part.
  2. Ask questions about the lab.
  3. Finish lab at home if not completed during the
    class session.
  4. Have your lab graded by the instructor on the
    next session by showing your work. You will
    receive a grade when you show your work.
  5. The grade will be available on Blackboard.

9
Other Class Work
  • I will have practice exercises for you to do on
    the computer during lectures.
  • You are required to do the practice exercise and
    not work on anything else!!!!
  • No grading for practice exercises.
  • Cover topics discussed in order to provide hands
    on understanding.

10
Exams
  • 2 quizes 5 points each
  • Exam 1 10 points
  • Exam 2 25 points
  • Exam 3 35 points
  • Consist of
  • questions about topics discussed
  • Small programs
  • Hand written.

11
Expectations
  • Attendance in Lectures and Labs
  • Take notes during lectures!
  • Completion of Quizzes and Exams
  • Four to Six Hours per Week on Homework
  • No Cheating
  • Have fun!!

12
Rules
  • No Swearing or Other Inconsiderate Behavior
  • Turn Off Cell Phones during lectures.
  • Questions, Discussion, Ideas Welcome.
  • No cell phones, no other material allowed on the
    desk during quizzes or exams.

13
Excuses
  • Exam, Quiz Dates Already Posted. No make ups
    except in case of emergency.
  • If Emergency
  • Doctor/Hospital Note

14
Unacceptable Excuses
  • Slept Late
  • Felt Sick
  • Im Just a Freshman
  • Roommate Ate My Alarm Clock/Textbook/Underwear
  • Missed Bus
  • Had a Game/Match/Practice
  • Didnt Know When Exam/Quiz Was
  • If Any of Above Happen, Get to Class As SOON as
    Possible!!!

15
CS 105 - Ethics
  • Exams
  • Closed Book, Closed Notes, Closed Everything
  • Nothing in Ears (mp3 players, cell phones,
    etc.)
  • Labs Should Be Done Independently

16
CS 105 Where to Get Help
  • www.cs.iit.edu/cs105
  • Internet Search for C tutorial, or C
    help
  • GET HELP EARLY RATHER THAN LATER!!!

17
CS 105 Web Page
  • http//www.cs.iit.edu/cs105
  • Click on Syllabus
  • Weekly Assignments
  • Quiz and Exam Dates
  • Lecture Slides
  • Other Course Information

18
CS105 Labs (Cont)
  • All Labs Assigned from Textbook (Malik)
  • Work on Labs on Personal PC, or Campus Computers
  • Save .cpp File(s) to Floppy or flash drive, or
    send to yourself in email and Bring to Lab
    Section for Discussion and Questions

19
Course Philosophy
  • Computer Science Side
  • Problem Solving
  • Logical Thought
  • Programming in C
  • Real World Side
  • Human Nature
  • Corporate World
  • Surviving during and after College

20
Problem Solving
  • Arrange a Deck of Cards by Suit and Rank
  • How Would You Do This?
  • How Would You Tell a Child to Do This?
  • How Would You Tell a Computer to Do This?

21
Problem Solving
  • CS 105 Develops Logic Skills to Solve Problems by
    Writing a Program
  • A Program is a Problem Solving Tool
  • Computers Follow Instructions Given to Them
  • Computers Do Not Have Intuition
  • Computers Do Not Make Decisions on Their Own

22
Why Use a Program?
  • Computers Perform Tasks Many Times Faster than a
    Person
  • Computers Are More Consistent than a Person
  • Computers Can Work 24-7

23
Terminology
  • Source Code the Original Problem-Solving,
    Logical Solution Written in a Programming
    Language (e.g. C)
  • Compiling the Action of Turning the Source Code
    into a Format the Computer Can Use
  • Linking the Action of Bringing in Already
    Written Code (Libraries) for Use in a New Program
  • Executable the Result of Compiling and Linking a
    Source Program the .exe file that the Computer
    Can Run

24
Terminalogy
  • Pseudocode Writing your thoughts for solving the
    problem (the program) in a combination of English
    sentences and programming (i..e C)
    instructions.
  • Could take many attempts before the solution make
    sense.

25
Syntax
  • A programming language has
  • Definite rules as to how to write instructions
    called the Grammar and Syntax of the
    language. Pretty much like a spoken language.
  • Has definite words and symbols that make up the
    instructions called keywords. Pretty much like
    the dictionary of a spoken language.

26
C Required Elements
  • Every C Program Must Have
  • int
  • main()

27
Explanation
  • In the previous slide
  • int , main are keywords.
  • (), , are symbols
  • How the keywords and the symbols appear in our
    programm, is guided by the grammar/syntax of the
    language .
  • i.e. the syntax requires that every C program
    start with the keyword int followed by the
    keyword main followed by ().

28
Explanation
  • The symbol indicates that the programming
    instructions start after the symbol.
  • The symbol indicates the end of the programming
    instructions.
  • The keyword main () indicates the name of a
    function (by the name main ).
  • function is a term used to describe a specific
    task that a program has to perform.

29
Explanation
  • A program can have many tasks, therefore many
    functions.
  • The Grammatical rule that we have learned so far
    is that
  • EVERY C PROGRAM MUST HAVE A FUNCTION CALLED
    main
  • AND THAT THE SYMBOLS () MEAN FUNCTION
  • AND THAT THE INSTRUCTIONS FOR THE FUNCTION
    (TASK) START AFTER THE SYMBOL AND END WITH THE
    SYMBOL

30
How the program is understood by the computer
  • A computer understands machine level instructions
    which consist of a series of 1 and 0.
  • In other words machine level instructions are
    coded instructions.

31
How the program is understood by the computer
  • The program that we write has to
  • Be checked for compliance to the grammar and
    syntax of the language.
  • Be converted to machine level instructions.
  • A software tool called the compiler is
    responsible for the above two tasks.

32
How the program is understood by the computer
  • If the compiler finds errors (the first task of
    the compiler)
  • It provides you with messages and clues as to the
    kind of grammatical or syntactical errors found.
  • It refuses to perform the second task (the
    translation to machine coded instructions), until
    all errors are corrected.

33
How the program is understood by the computer
  • After you correct all errors the compiler will
    perform the second task
  • You know that the second task of the compiler was
    performed because it produces the executable file
    (the file with the coded machine level
    instructions).
  • Clicking on the executable file will cause the
    computer to execute the machine level
    instructions generated by the compiler based on
    your C level instructions.

34
Logical tasks
  • Is my program performing the tasks I intended for
    it?
  • Note A compiler can not check for logical
    errors only grammatical and syntactical errors
    are checked.
  • i.e. suppose the correct logic in the task that
    you want the computer to perform requires the
    addition of two numbers but instead your
    instruction is to multiply the two numbers.

35
Your First Program
  • // George Koutsogiannakis
  • // CS105
  • // Summer Section 2
  • include ltiostreamgt
  • using namespace std
  • int
  • main()
  • cout ltlt Hello World!! ltlt endl
  • return (0)

36
Your First Program
  • Notice that certain information about who wrote
    the program, the class the person attends and the
    section number as well as the date are in written
    as comments.
  • Same information must appear in every program you
    write in this class as part of the labs or
    exams/quizzes!!!
  • Comments are disregarded by the compiler and they
    are marked with // in each line.

37
Writing a C Program
  • Write Pseudocode (Design)
  • Translate Pseudocode into C Source Code in
    Visual C
  • Edit Code
  • Compile
  • Link

38
What Is Pseudocode?
  • Every Programmers Way of Writing Down Steps in
    Solving a Problem
  • Steps in Creating Pseudocode
  • Understand the Problem
  • Decide How to Solve the Problem
  • Write the Solution Using a Logical Sequence of
    Statements
  • Design Issues Apply to almost ANY Vocation

39
Writing Source Code
  • Source Code Is the Actual Program Code that Will
    Run Once Compiled and Linked
  • Pseudo Code Should Be Easily Translated into
    Source Code

40
Preprocessing
  • Preprocessing Is the Actions Taken Before a
    Source File Is Handed Off to the Compiler
  • Outcome of Preprocessing Must Still Be a Correct
    Source Code File
  • Example Preprocessing Statement
  • include Includes Text of Other Source Files
  • include Usually Occur at Top of Program
  • Pound Sign () Must Be in First Position on Line
  • Example include ltiostreamgt for Typical Input
    and Output Operations in C

41
Compiler
  • Converts Source Code into an Object File or
    Machine Code
  • Each Change to Source File Requires a
    Recompilation
  • Compiler Detects Syntax Errors
  • Syntax Error a Non-Proper, Not Allowable,
    Sequence of Characters or Words Given a
    Particular Language

42
Syntax Errors
  • Spelling Errors Examples
  • Undefined Variable Name
  • Unrecognized Keyword
  • Cannot Find Include File or Library
  • Punctuation Errors Examples
  • Missing Curly Braces
  • Missing Semicolons
  • Malformed Comments
  • Syntax Errors Are Listed at Bottom of Screen When
    Compilation Is Complete

43
Syntax Errors (Cont)
  • Syntax Errors Are Listed at Bottom of Screen When
    Compilation Is Completed
  • Two Kinds of Messages
  • Warning Compiler Thinks There Is a Problem, but
    Lets It Go By Without Failing
  • Error Compiler Finds an Error and Fails to
    Compile
  • First Error in Program May Cause Other Errors
    to Show Up
  • General Rule Fix First Error (and Any Obvious
    Errors) Then Recompile

44
Linking
  • Links (Connects) Object Code with External
    Libraries, which Contain Functions (Already
    Written and Compiled Code) to Use with Another
    Program
  • Creates an Executable File
  • An Executable File (e.g. .exe File) Can Be Run
  • If Linker Cannot Find Libraries, Error Message
    Are Generated

45
Logic Errors Bugs
  • Also Called Semantic or Run-Time Errors
  • Program Compiles, but Doesnt Produce the
    Expected Results
  • Examples
  • Program Keeps Running Forever (Infinite Loop)
  • Nothing Happens
  • Program Output Is Incorrect
  • Error Message at Run Time (e.g. Dividing by 0)
  • Errors May Be Intermittent
  • May Be Able to Find Semantic Problems with
    Debugger

46
Detecting Bugs
  • Running Program Should Be Tested Several Times
    with Different Inputs
  • Test Plan Series of tests (e.g., inputs) that
    have predetermined expected outputs.
  • Running Program Should Be Tested Several Times
    under All Potential Conditions
  • When Errors Detected Analysis Needed Debugging
    Mechanism

47
Comments
  • Comments Describe a Program
  • // Comment to end of line
  • / Comment until first occurrence of star slash
    /
  • Difficult to Understate Importance of Good
    Comments
  • Should Be at Beginning of Program (Overall
    Summary)
  • Should Be Next to Variable Declaration Briefly
    Describing Uses of Variable
  • Should Be Anywhere in Program Where Unobvious
    Coding Is Performed

48
Program Format
  • White Space
  • Not Recognized by Compiler
  • Indent (e.g. 3 Spaces) for Each New Function,
    Selection, or Loop

49
Variables
  • Identifiers Used to Store Values that May Change
  • Every Variable Has a Type What Kind of Value
    (e.g., Integer, Floating Point Number, Character)
    Is Begin Stored
  • Every Variable Has a Value which Is Assigned and
    Can Be Changed
  • Every Variable Must Be Declared, which Sets Aside
    Memory for the Storage Location

50
Declaring a Variable
  • Declaration Normally Comes after a Function
    Definition Opening Curly Brace int main()
  • int num1 //variable
    declaration
  • num1 10 // variable assignment
  • cout ltlt num1 // variable output
  • Declaration Includes Type and the Name of the
    Variable
  • All Variables Must Be Declared before Being Used

51
Variables and Main Memory
Main Memory
  • int num
  • num 10
  • num 15

num
ltgarbagegt
num
10
num
15
52
Main Memory
  • Storage Location of Data in a Computer
  • Used When a Program Is Running
  • Wiped Clean When Computer Rebooted
  • Bit a logical single 1 or 0 value (sometimes
    referred to as True or False)
  • Byte Basic Unit of Storage (Can Store One Letter
    of the Alphabet)
  • Consists of 8 Bits.
  • Kilobyte (KB) 1000 (or 1024) Bytes (Pages of
    Text)
  • Megabyte (MB) 1,000,000 Bytes (Large Pictures)
  • Gigabyte (GB) 1,000,000,000 Bytes (Music Files,
    Video Files)

53
Initialization and Assignment
  • Initialization Value Given to Variable at
    Declaration
  • Assignment Value Given to Variable in Execution
    Statement

54
Variable Initialization
  • int main()
  • int num1 10 //variable
    declaration
  • // with initialization
  • cout ltlt num1 // variable output

55
Built-In (or Primitive) Data Types for Variables
  • int Integer Range of Typically -32,768 to 32,767
    (machine and compiler dependent)
  • float Real Number (i.e., integer part, decimal
    part, and exponent part) Range of Typically
    10e-38 to 10e38
  • double Larger Real Number (10e-308 to 10e308)
  • char Character

56
Naming Variables in C Identifiers
  • Can Use Letters Remember That C is Case
    Sensitive (e.g., NumWidgets Is Not the Same as
    numwidgets)
  • Can Use Digits 0-9, and Underscore
  • Cannot Start with a Digit
  • Cannot Contain Spaces or Other Characters
  • Typically Maximum of 32 Characters
  • Cannot Use C Keywords

57
Naming Variables (Cont)
  • Should Use a Meaningful, Descriptive Name so that
    Variables Use Is Easily Understood
  • Examples
  • counter, second, minute, length, width
  • Be Consistent with Case Usually Lower Case with
    Upper Case for Second Part of Variable Name
  • Examples
  • averageRainfall, totalStudentGrades,
    maxBuildingHeight, minPackageWeight

58
Variable Scope
  • Scope Area of a Program within which a Variable
    Can Be Referenced
  • Variable Definitions Are Recognized in the Curly
    Braces in which They Were Defined
  • Variables Declared Outside of Functions Are
    Recognized from the Point Declaration through the
    Rest of the Program

59
Named Constants
  • Constant An Identifier that Is Initialized to a
    Value that Cannot Change
  • Usually Declared at Top of Program using Keyword
    const
  • Standard Naming of Constants Is to Use All Upper
    Case Letter with or without Underscore between
    Words
  • All Constants Must Be Initialized
  • Syntax const int MAXHT 100

60
Advantages of Constants
  • Easier to Understand
  • Easier to Modify
  • Example Compare using Number 5000 in Program
    versus Constant MAXHT

61
Named Constants
  • const int MAXHT 100
  • main()
  • ...
  • currentHeight gt MAXHT
  • ...
  • bridgeHeight MAXHT
  • ...
  • bridgeHeight newAddition gt MAXHT
  • ... // used MAXHT 223 times in this program

62
Literal Constants (Values)
  • Constants Whose values Are Already Known
  • Characters (Specified Inside Single Quotes)
  • A , a , 5 , , \n (newline) , \0
    (NULL Character)
  • Integers
  • 10, 1345, -34
  • Float or Double
  • 2.3, -45.18, 10.6e6
  • String (Specified Inside Double Quotes)
  • HELLO , What a great deal. , 5

63
Input and Output
  • Also Known as I/O
  • Output Stream cout ltlt variable
  • Input Stream cin gtgt variable
  • New Line endl
  • All C Statements End in Semicolon ()

64
Input and Output Example
  • include ltiostreamgt
  • using namespace std
  • int
  • main()
  • int numEntered
  • cout ltlt Please enter an integer
  • cin gtgt numEntered
  • cout ltlt Thanks, you entered ltlt numEntered
    ltlt . ltlt endl

65
Characters and Strings
  • Standard Template Library (STL) Library of C
    Functions Used Worldwide
  • String Type NOT Built-in in C
  • String Type Defined in STL
  • To Use STL Strings
  • include ltiostreamgt
  • include ltstringgt
  • using namespace std
  • string lastName

66
STL Strings
  • Declaration string yourName
  • Assigning a Value to a String
  • yourName A. Goose
  • String Constants (Values) Must Be Enclosed in
    Double Quotes

67
Input String Example
  • include ltiostreamgt
  • include ltstringgt
  • using namespace std
  • int
  • main()
  • string lastName
  • cout ltlt Enter your last name
  • cin gtgt lastName
  • cout ltlt Your last name is ltlt lastName
    ltlt endl
  • return(0)

68
Expressions
  • Expression A Sequence of One or More Identifiers
    and Operators that Evaluates to a Value
  • Operator A Symbol Expressing a Way to Modify a
    Value or Values (e.g., for Addition)
  • Operand A Value Being Modified by an Operator
  • Example Expressions
  • 5
  • currentHeight
  • currentHeight 10

69
Arithmetic Expressions
  • Standard Arithmetic Operations Can Be Performed
    Addition, Subtraction, Multiplication, Division
  • Standard Arithmetic Operators Can Be Used for
    These Operations , -, , /
  • Others
  • - Modulo (Mod) Remainder after Integer
    Division
  • -- Decrement (Subtract 1)
  • Increment (Add 1)

70
Order of Operations
  • Precedence Level of Importance of Operations
  • Multiplicative Operators Have Higher Precedence
    than Additive Operators
  • , /, Higher
  • , - Lower
  • Associativity Order of Operation for Equal Level
    Precedence
  • Most Operators Have Left-to-Right Associativity
  • Use Parentheses to Force Differing Precedence of
    Operations

71
Know for the Quiz 1- July 07
  • All Terms (Underlined Items)
  • Variable Declaration, Initialization, and
    Assignment
  • Constant Declaration
  • Expressions
  • Operators
  • Input (cin) and Output (cout)

72
Know for the Quiz
  • Read Chapters 1 2 , pages 28-67, 67-77, 77-86,
    86-100, 117-124. (Note Edition 5 page numbers)
  • Ask questions about the exercises if unable to
    complete Lab 0 OR Lab 1.
  • Practice with additional exercises from text on
    your own.
  • Study examples material distributed in class.
  • Study Lect 01, 02, 03 slides. Also study the
    first 3 slides of Lect 04, 05
  • Quiz will be given at the end of class period,
    after the lecture part.

73
Quiz Format
  • 15 questions where you are given a concept and
    you are asked to match it against a list of
    definitions (3/5 of the grade).
  • Write one program (2/5 of the grade) that
    requires
  • Declarations of constants and variables.
  • Input from user.
  • Arithmetic expressions including increment or
    decrement operators.
  • Display of program output
Write a Comment
User Comments (0)
About PowerShow.com