Great way to learn is by example so fire up Visual Studios C++ 2015 (at home make sure you custom install with C++ - no longer default) by Deborah R. Fowler.

Slides:



Advertisements
Similar presentations
 C++ programming facilitates a disciplined approach to program design. ◦ If you learn the correct way, you will be spared a lot of work and frustration.
Advertisements

Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 2: Your First Program.
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.
1 Session-I & II CSIT-121 Spring 2006 Session Targets Introducing the VC++.NET Solving problems on computer Programming in C++ Writing and Running Programs.
1 9/1/06CS150 Introduction to Computer Science 1 What Data Do We Have? CS 150 Introduction to Computer Science I.
A simple C++ program /* * This program prints the phrase "Hello world!" * on the screen */ #include using namespace std; int main () { cout
C# Programming: From Problem Analysis to Program Design1 2 Your First C# Program C# Programming: From Problem Analysis to Program Design 2 nd Edition.
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
C# Programming: From Problem Analysis to Program Design1 2 Your First C# Program.
Chapter 3 Getting Started with C++
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 2 - Welcome Application: Introduction to C++
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 2 - HelloWorld Application: Introduction to.
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
Creating your first C++ program
Computer Science I How to Configure Visual Studio.NET 2003 for C++ Colin Goble.
Chapter 02 (Part III) Introduction to C++ Programming.
3. The Nuts and Bolts of C++ Computer Programming 3. The Nuts and Bolts of C++ 1 Learning the C++ language 3. The Nuts and Bolts of C++
Week 1 Algorithmization and Programming Languages.
Programming Fundamentals. Today’s Lecture Why do we need Object Oriented Language C++ and C Basics of a typical C++ Environment Basic Program Construction.
COMPUTER PROGRAMMING. A Typical C++ Environment Phases of C++ Programs: 1- Edit 2- Preprocess 3- Compile 4- Link 5- Load 6- Execute Loader Primary Memory.
CHAPTER 2 PART #1 C++ PROGRAM STRUCTURE 1 st semester H 1 King Saud University College of Applied studies and Community Service Csc 1101 By:
Chapter 0 Getting Started. Objectives Understand the basic structure of a C++ program including: – Comments – Preprocessor instructions – Main function.
Basic Program Construction
1 A simple C++ program // ======================================================= // File:helloworld.cpp // Author:Vana Doufexi // Date:1/4/2006 // Description:Displays.
Chapter 2 part #1 C++ Program Structure
1 8/31/05CS150 Introduction to Computer Science 1 Hello World!
C++ LANGUAGE TUTORIAL LESSON 1 –WRITING YOUR FIRST PROGRAM.
Introduction to C++.  Computers: CPU, Memory & Input / Output (IO)  Program: Sequence of instructions for the computer.  Operating system: Program.
1 Structure of Simple C++ Program Chapter 1 09/09/13.
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
Linux CSE 1222 CSE1222: Lecture 1BThe Ohio State University1.
STRUCTURED PROGRAMMING Complete C++ Program. Content 2  Main Function  Preprocessor directives  User comments  Escape characters  cout statement.
DEVRY CIS 170 C I L AB 1 OF 7 G ETTING S TARTED Check this A+ tutorial guideline at
C# Programming: From Problem Analysis to Program Design
Bill Tucker Austin Community College COSC 1315
Introduction to C++ Programming
C++ First Steps.
Chapter 1.2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
Topic Pre-processor cout To output a message.
CMPT 201.
CHAPTER 2 PART #1 C++ PROGRAM STRUCTURE
Introduction to C++ Programming
Chapter 2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
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.
Completing the Problem-Solving Process
Chapter 2, Part I Introduction to C Programming
Chapter 2 part #1 C++ Program Structure
Beginning C++ Programming
C# Programming: From Problem Analysis to Program Design
Chapter 2 – Getting Started
2.1 Parts of a C++ Program.
Understanding the Visual IDE
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.
1. Open Visual Studio 2008.
Lab 1 Introduction to C++.
Introduction to C++ Programming
Creating the First Program
Programming Introduction to C++.
Programs written in C and C++ can run on many different computers
Lecture 2 Fall 2011 September 13-15, 2011 Ghufran Ahmed
Capitolo 1 – Introduction C++ Programming
Reading from and Writing to Files
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
Introduction to Programming - 1
Chapter 1 c++ structure C++ Input / Output
Reading from and Writing to Files
Chapter 2 part #1 C++ Program Structure
Presentation transcript:

Great way to learn is by example so fire up Visual Studios C++ 2015 (at home make sure you custom install with C++ - no longer default) by Deborah R. Fowler www.deborahrfowler.com

New Project can be created two ways … i i New Project can be created two ways … Under the File menu select New then Project

Under Templates: Visual C++ and Win32 Console Application

If you hit next you will see this, hit finish Default settings are correct

Now you have the screen where you will type in your program Erase this Now you have the screen where you will type in your program So why leave stdafx.h …

stdafx.h - is a precompiled file (all things above it are assumed precompiled) Stands for Application Framework eXtensions. Includes precompiled files that are frequently used and rarely changed. If you type in examples from the textbook, make sure you have this line

Now type in your first program

#include <iostream> #include stdafx.h #include <iostream> int main() { std::cout << “Hello World! \n”; std::cout << “Press Enter or Return to exit.”; std::cin.get(); return 0; }

Build invokes the compiler Shows it worked correctly

Run the program by selecting Start Debugging from the Debug pull-down menu. If it is out of date it will ask “do you want to build your project “ (invokes compiler) (or run by pressing the green arrow)

int main() - is a funtion Now let’s examine the code: C++ provides ways to do input/output #include tells the pre-processor this is from a standard library C++ programs have a function called main() which is the starting point int main() - is a funtion A function is a group of programming code that does some work and returns a value (return 0; will be our last line).

std is the namespace (like a phone number’s area code) std::cout std is the namespace (like a phone number’s area code) :: scope resolution operator Note that statements end in a semicolon in C++ Will print what is in the quotation marks (string literal)

These lines are to allow us to see the console window Why are these here? These lines are to allow us to see the console window It prints the message and then waits for the user to input a value Right now delete those two lines and run your program (then add them back in)

Coding standards for this class will have these lined up as above Note that the main() function body (group of statements) is surrounded by curly braces – this defines a block Coding standards for this class will have these lined up as above

What are coding standards What are coding standards? All code written in class or on the job must conform to coding standards (the use of naming conventions and whitespace – formatting – of the program) This is not the same as syntax – the rules to construct a legal statement or expression

A complete list of the coding standards can be found on the class website – these will be mentioned as we introduce items as well

In C++, you can use the keyword “using” and namespace to avoid having to type “std::” each time we use cout and cin Example: using namespace std (called a using directive) Example: using std::cout (called a using declaration)

You may see older C-style /* */ comment Comments in C++ are // You may see older C-style /* */ Just like whitespace (tabs, spaces, newlines), ignored by the compiler, there to make code more readable

This is okay exit normal

Error tab if exit is not code 0

For example, a missing semicolon

Click on the error, takes you to the line of proximity to the error

Fix the first error – compile or run again – success!

Congratulations! You have written a successful C++ program using Visual Studios 2015