Practice 1 Seoul National University Graphics & Media Lab.

Slides:



Advertisements
Similar presentations
Lecture Computer Science I - Martin Hardwick The Programming Process rUse an editor to create a program file (source file). l contains the text of.
Advertisements

Programming Languages and Paradigms The C Programming Language.
Making Choices in C if/else statement logical operators break and continue statements switch statement the conditional operator.
COMP1180 Review Date: 4 March, 2009 Time: 10:30am - 12:20pm Venue: –CS students -- FSC801C and FSC801D –IS and other students -- OEE1017 Remarks: – 1)
COMP2004 Programming Practice Sam Holden Department of Computer Science University of Sydney.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 15 - C++ As A "Better C" Outline 15.1Introduction.
Basic Elements of C++ Chapter 2.
 2003 Prentice Hall, Inc. All rights reserved. 1 Functions and Recursion Outline Function Templates Recursion Example Using Recursion: The Fibonacci Series.
1 Introduction to C++ Noppadon Kamolvilassatian Department of Computer Engineering Prince of Songkla University.
M. Taimoor Khan #include void main() { //This is my first C++ Program /* This program will display a string message on.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
Introduction to C++ // Program description #include directives int main() { constant declarations variable declarations executable statements return.
Rossella Lau Lecture 1, DCO10105, Semester B, DCO10105 Object-Oriented Programming and Design  Lecture 1: Introduction What this course is about:
CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 15 - C++ As A "Better C" Outline 15.1Introduction 15.2C A Simple Program: Adding Two Integers.
C++ Lecture 1 Friday, 4 July History of C++ l Built on top of C l C was developed in early 70s from B and BCPL l Object oriented programming paradigm.
C++ / G4MICE Course Session 1 - Introduction Edit text files in a UNIX environment. Use the g++ compiler to compile a single C++ file. Understand the C++
C++ Basics II Lecture 2 Seoul National University Graphics & Media Lab.
2: Basics Basics Programming C# © 2003 DevelopMentor, Inc. 12/1/2003.
Chapter 7 Conditional Statements. 7.1 Conditional Expressions Conditions - compare the values of variables, constants and literals using one or more relational.
C++ Basics Programming. COMP104 Lecture 5 / Slide 2 Introduction to C++ l C is a programming language developed in the 1970s with the UNIX operating system.
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
A Introduction to Computing II Lecture 1: Java Review Fall Session 2000.
CMSC 104, Version 8/061L09VariablesInC.ppt Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement Reading.
2. C FUNDAMENTALS. Example: Printing a Message /* Illustrates comments, strings, and the printf function */ #include int main(void) { printf("To C, or.
Session 2 Operators, Decisions and Loops. Objectives Operators Casting data Decision marking structures Loops break, continue, return.
CHAPTER 4 FUNCTIONS Dr. Shady Yehia Elmashad. Outline 1.Introduction 2.Program Components in C++ 3.Math Library Functions 4.Functions 5.Function Definitions.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
Chad’s C++ Tutorial Demo Outline. 1. What is C++? C++ is an object-oriented programming (OOP) language that is viewed by many as the best language for.
Chapter 2 Creating a C++ Program. Elements of a C++ Program Four basic ways of structuring a program Four basic ways of structuring a program 1.Sequencing.
 2000 Prentice Hall, Inc. All rights reserved Program Components in C++ Function definitions –Only written once –These statements are hidden from.
C syntax (simplified) BNF. Program ::= [ ] Directives ::= [ ] ::= | |… ::=#include > ::=#define.
Chapter 15 - C++ As A "Better C"
C++ Lesson 1.
Chapter 1.2 Introduction to C++ Programming
Chapter Topics The Basics of a C++ Program Data Types
Chapter 1.2 Introduction to C++ Programming
Computer Science 210 Computer Organization
Chapter 1.2 Introduction to C++ Programming
ECE Application Programming
Unit-1 Introduction to Java
Basic Elements of C++.
CSC113: Computer Programming (Theory = 03, Lab = 01)
CSC113: Computer Programming (Theory = 03, Lab = 01)
Basic Elements of C++ Chapter 2.
Computer Science 210 Computer Organization
Introduction to Programming
Introduction to Java Programming
An Introduction to Java – Part I, language basics
Variables in C Topics Naming Variables Declaring Variables
C# Basics These slides are designed for Game Design Class
Govt. Polytechnic,Dhangar
Variables in C Topics Naming Variables Declaring Variables
Seoul National University
Information Technology for Engineers
Java Programming Review 1
2. Second Step for Learning C++ Programming • Data Type • Char • Float
Engineering Problem Solving with C++ An Object Based Approach
Engineering Problem Solving with C++ An Object Based Approach
Chapter 15 - C++ As A "Better C"
Programming Language C Language.
Fundamental Programming
Welcome back to Software Development!
Seoul National University
The switch Statement When we want to compare a variable against several values to see which one it has, we can use the switch statement: switch (status)
Variables in C Topics Naming Variables Declaring Variables
Variables in C Topics Naming Variables Declaring Variables
Variables in C Topics Naming Variables Declaring Variables
Seoul National University
Variables in C Topics Naming Variables Declaring Variables
Presentation transcript:

Practice 1 Seoul National University Graphics & Media Lab

Goal of this class Learn Objected-Oriented Programming – Object-Oriented Programming – in C++ Use C++ like Korean.

Class Introduction Schedule 10+ short program assignments (at each class) 1 large program (as term project) Reference (temporary) ETL

Assignment Submission Send – To – Mail Title : Practice_Week01_Assignment – Mail Contents Student ID + Name – Attachment One Source code file Write a comment about your student ID and name on the top of the attached file Until Friday 11:59 PM

Hello World! Use IDE, Compile, Link, Execute.

Programming Environment Visual Studio 2008

Hello World! #include void main() { std::cout << “Hello, World” << std::endl; }

Assignment Brief review quickly …

Types, Variables Primitive built-in types – void – bool, char, w_char, short, int, long, float, double – unsigned char, unsigned int, … #include void main() { int height = 11, width = 9, length = 40; int result = height * width * length; float pi = f; }

Basic Expressions Arithmetic expressions +, -, *, /, % Numerical predicates ==, !=, >, =, <=

Basic Expressions Conditional operator cond ? expr1 : expr2; #include void main() { std::cout << ((3 < 4) ? 3 : 4); }

Basic Statements Conditional statement – if … else, switch #include void main() { const int v = 5; if(v < 3)std::cout << “v is less than 3”; else if(v < 5) std::cout << “v is less than 5”; else if(v < 7) std::cout << “v is less than 7”; else std::cout << “v is larger than 7”; }

Basic Statements Conditional statement – if … else, switch #include void main() { const int v = 5; switch(v) { case 3: std::cout << “v is 3”; break; case 5: std::cout << “v is 5”; break; case 7: std::cout << “v is 7”; break; default : std::cout << “v is not 3 or 5 or 7” }

Basic Statements Loops – for, while Problem – Do summation from 1 to 10 #include void main() { int sum = 0; for(int i=1;i<=10;++i) sum += i; std::cout << sum; }

Basic Statements Loops – for, while Problem – Do summation from 1 to 10 #include void main() { int sum = 0, i = 1; while(i <= 10) { sum += i; i++; } std::cout << sum; }

Function How to define a simple function ? #include void main() { const int height = 3, width = 5, length = 7; std::cout << " Volume is " << height*width*length; } #include int volume(int h, int w, int l) { return h*w*l; } void main() { const int height = 3, width = 5, length = 7; std::cout << " Volume is " << volume(height,width,length); }

Assignment - Factorial Write a function int factorial(int N) Code two versions of factorial function: 1) using repetition 2) using recursive function Output – factorial(5) : return 120 – factorial(1) : return 1