CSE Module 1 A Programming Primer

Slides:



Advertisements
Similar presentations
Lecture Computer Science I - Martin Hardwick Strings #include using namespace std; int main () { string word; cout
Advertisements

Class Scope class Student { private: string id; string firstName, lastName; float gpa; public: void Read() { cin >> id >> firstName >> lastName >> gpa;
Your First C++ Program Aug 27, /27/08 CS 150 Introduction to Computer Science I C++  Based on the C programming language  One of today’s most.
A simple C++ program /* * This program prints the phrase "Hello world!" * on the screen */ #include using namespace std; int main () { cout
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
General Computer Science for Engineers CISC 106 Lecture 26 Dr. John Cavazos Computer and Information Sciences 04/24/2009.
Programming is instructing a computer to perform a task for you with the help of a programming language.
C++ Programming Language Day 1. What this course covers Day 1 – Structure of C++ program – Basic data types – Standard input, output streams – Selection.
February 11, 2005 More Pointers Dynamic Memory Allocation.
CS31: Introduction to Computer Science I Discussion 1A 4/9/2010 Sungwon Yang
CSC 107 – Programming For Science. Announcements  Memorization is not important, but…  … you will all still be responsible for information  Instead.
Current Assignments Homework 3 is due tonight. Iteration and basic functions. Exam 1 on Monday.
First steps Jordi Cortadella Department of Computer Science.
C++ Basics #7 Basic Input and Output. In this video Standard output (cout) Standard input (cin) stringstream.
Review the following : Flowcharting Variable declarations Output Input Arithmetic Calculations Conditional Statements Loops.
CSC1201: Programming Language 2 Lecture 1 Level 2 Course Nouf Aljaffan (C) CSC 1201 Course at KSU1.
1 A simple C++ program // ======================================================= // File:helloworld.cpp // Author:Vana Doufexi // Date:1/4/2006 // Description:Displays.
A first program 1. #include 2. using namespace std; 3. int main() { 4. cout
Quiz 2 Results. What Is Wrong? #include using namespace std int Main() { // Say Hello 4 times for(i == 0; i < 3; i++) { cout >> "Hello World!"
Think First, Code Second Understand the problem Work out step by step procedure for solving the problem (algorithm) top down design and stepwise refinement.
LESSON 2 Basic of C++.
1 Structure of Simple C++ Program Chapter 1 09/09/13.
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
CSE 232: Moving Data Within a C++ Program Moving Data Within a C++ Program Input –Getting data from the command line (we’ve looked at this) –Getting data.
General Computer Science for Engineers CISC 106 Lecture 27 Dr. John Cavazos Computer and Information Sciences 04/27/2009.
Looping I (while statement). CSCE 1062 Outline  Looping/repetition construct  while statement (section 5.1)
ANNOUNCEMENT The missed lecture will be made up this Monday evening in the Tech PC classroom (MG51). A tentative time interval is 6:30-8:00. The exact.
LESSON 2 Basic of C++.
CMSC 202 Lesson 2 C++ Primer.
Two-Dimensional Arrays Lesson xx
Session 1 - Introduction
Command Line Arguments
CO1401 Programming Design and Implementation
CSC 113: Computer Programming (Theory = 03, Lab = 01)
Introduction to C++ October 2, 2017.
Programming Fundamentals
solve the following problem...
Parallel Arrays Parallel array =>Two or more arrays with the same number of elements used for storing related information about a collection of data. Example:
Function Basics.
Random Number Generation
C++ fundamentals Lecture 1, Chapter 2 – pp /22/2018 Y K Choi.
Functions A function is a “pre-packaged” block of code written to perform a well-defined task Why? Code sharing and reusability Reduces errors Write and.
Basic Input and Output C++ programs can read and write information using streams A simple input stream accepts typed data from a keyboard A simple output.
אבני היסוד של תוכנית ב- C++
אבני היסוד של תוכנית ב- C++
הרצאה 03 אבני היסוד של תוכנית ב- C
Counting Loops.
Starting Out with C++: From Control Structures through Objects
Pointers & Functions.
اصول کامپیوتر ۱ مبانی کامپیوتر و برنامه‌سازی
Code::Block vs Visual C++
Mr. Dave Clausen La Cañada High School
Jeff West - Quiz Section 4
CSE Module 1 A Programming Primer
CSE Module 1 A Programming Primer
CSE Module 1 A Programming Primer
Lecture 2 Fall 2011 September 13-15, 2011 Ghufran Ahmed
Arithmetic Operations
Using string type variables
Pointers & Functions.
(Dreaded) Quiz 2 Next Monday.
Strings Skill Area 313 Part C
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
Programming Strings.
Chapter 1 c++ structure C++ Input / Output
CSE Module 1 A Programming Primer
getline() function with companion ignore()
Module 2 - Part 1 Variables, Assignment, and Data Types
Module 3 Selection Structures 12/7/2019 CSE 1321 Module 3.
Methods and Data Passing
Presentation transcript:

CSE 1321 - Module 1 A Programming Primer 10/4/2019 CSE 1321 Module 1

Ps Skeletons BEGIN MAIN END MAIN Note: every time you BEGIN something, you must END it! Write them as pairs! 10/4/2019 CSE 1321 Module 1

Skeletons #include <iostream> int main() { std::cout << "Hello World!\n"; } Note: Capitalization matters! 10/4/2019 CSE 1321 Module 1

Skeletons #2 – Same thing! #include <iostream> using namespace std; int main() { cout << "Hello, World!" << endl; } Note: The “namespace” thing keeps you from having to type “std” all the time! 10/4/2019 CSE 1321 Module 1

Ps Printing BEGIN MAIN PRINT “Hello, World!” PRINT “Bob” + “ was” + “ here” END MAIN Ps 10/4/2019 CSE 1321 Module 1

Printing #include <iostream> using namespace std; int main() { cout << "Hello, World!" << endl; cout << "Bob" << " was" << " here!" << endl; } 10/4/2019 CSE 1321 Module 1

Declaring/Assigning Variables BEGIN MAIN CREATE userName CREATE studentGPA userName ← “Bob” studentGPA ← 1.2 END MAIN userName “Bob” studentGPA 1.2 Ps 10/4/2019 CSE 1321 Module 1

Declaring/Assigning Variables #include <iostream> #include <string> using namespace std; int main() { string username; float gpa; username = "Bob"; gpa = 1.2f; } 10/4/2019 CSE 1321 Module 1

Reading Text from the User BEGIN MAIN CREATE userInput PRINT “Please enter your name” READ userInput PRINT “Hello, ” + userInput END MAIN Ps 10/4/2019 CSE 1321 Module 1

Reading Text from the User #include <iostream> #include <string> using namespace std; int main() { string userInput; cout << "Please enter your name: "; getline (cin, userInput); cout << "Hello, " << userInput << "!" << endl; } 10/4/2019 CSE 1321 Module 1

Reading Numbers from the User BEGIN MAIN CREATE userInput PRINT “Please enter your age: ” READ userInput PRINT “You are ” + userInput + “ years old.” END MAIN Ps 10/4/2019 CSE 1321 Module 1

Reading Numbers from the User #include <iostream> using namespace std; int main() { int age; cout << "Please enter your age: "; cin >> age; cout << "You are " << age << " years old." << endl; } 10/4/2019 CSE 1321 Module 1

Note There are times when reading strings and numbers immediately after one another is problematic. We’ll talk about that later. 10/4/2019 CSE 1321 Module 4