C++ LANGUAGE TUTORIAL LESSON 1 –WRITING YOUR FIRST PROGRAM.

Slides:



Advertisements
Similar presentations
Algorithms Series of mathematical or variable manipulations Integer a,b,c a = 12 b = 22 c = a * b (what is c?) 12 * 22 = 264.
Advertisements

Downloading, Installing, and Working with Dropbox.
1 eclipse Tips. 2 What is eclipse? Eclipse is a popular IDE (Integrated Development Environment) that we will use to create, compile, execute, and test.
 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.
INTRODUCTION T.Najah Al_Subaie Kingdom of Saudi Arabia Prince Norah bint Abdul Rahman University College of Computer Since and Information System CS240.
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 Lab Session-I CSIT120 Spring2001 Using Windows Using An Editor Using Visual C++ Using Compiler Writing and Running Programs Lab-1 continues (Session.
CS 2511 Fall  Windows:  Start->Specialized Academic Software- >Programming Languages->NetBeans->NetBeans IDE x.y.z  where x.y.z is a version.
C++ Programming Language Day 1. What this course covers Day 1 – Structure of C++ program – Basic data types – Standard input, output streams – Selection.
1 eclipse Tips. 2 What is eclipse? Eclipse is a popular IDE (Integrated Development Environment) that we will use to create, compile, execute, and test.
Google Training By: Amy Shannon and Dave Auwerda.
Today in CS161 Lecture #4 Solving Problems with Computers Walk through the Tic Tac Toe Algorithm Getting ready for Creating Programs Turn the Inches to.
1 INF160 IS Development Environments AUBG, COS dept Lecture 06 Title: Dev Env: Code::Blocks (Extract from Syllabus) Reference:
CS Tutorial 1 Getting Started with Visual Studio 2012 (Visual Studio 2010 are no longer available on MSDNAA, please choose Visual Studio 2012 which.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
C# B 1 CSC 298 Writing a C# application. C# B 2 A first C# application // Display Hello, world on the screen public class HelloWorld { public static void.
History of C and C++ C++ evolved from C ANSI C C++ “spruces up” C
An Introduction to Designing and Executing Workflows with Taverna Katy Wolstencroft University of Manchester.
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.
CS 114 – Class 02 Topics  Computer programs  Using the compiler Assignments  Read pages for Thursday.  We will go to the lab on Thursday.
By Noorez Kassam Welcome to JNI. Why use JNI ? 1. You already have significantly large and tricky code written in another language and you would rather.
Creating your first C++ program
Computer Science I How to Configure Visual Studio.NET 2003 for C++ Colin Goble.
1. Profile settings 2. Messaging system 3. Downloading files 4. Uploading files 5. Creating groups 6. Calendar events.
Downloading and Installing Autodesk Revit 2016
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++
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:
An Introduction to Designing and Executing Workflows with Taverna Aleksandra Pawlik materials by: Katy Wolstencroft University of Manchester.
Comments in Java. When you create a New Project in NetBeans, you'll notice that some text is greyed out, with lots of slashes and asterisks:
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
Downloading and Installing Autodesk Inventor Professional 2015 This is a 4 step process 1.Register with the Autodesk Student Community 2.Downloading the.
1 C++ Programming Basics Chapter 1 Lecture CSIS 10A.
Chapter 0 Getting Started. Objectives Understand the basic structure of a C++ program including: – Comments – Preprocessor instructions – Main function.
Making Python Pretty!. How to Use This Presentation… Download a copy of this presentation to your ‘Computing’ folder. Follow the code examples, and put.
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
Introduction to Python Lesson 1 First Program. Learning Outcomes In this lesson the student will: 1.Learn some important facts about PC’s 2.Learn how.
You will need Dev C++ to help you with this project. If you do not already have this programming tool on your device you can visit
1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile.
Python Lesson 1 1. Starter Create the following Excel spreadsheet and complete the calculations using formulae: 2 Add A1 and B1 A2 minus B2 A3 times B3.
Learners Support Publications Introduction to C++
Computer Programming A simple example /* HelloWorld: A simple C program */ #include int main (void) { printf (“Hello world!\n”); return.
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
Part 1 Learning Objectives To understand that variables are a temporary named location to store data and that programmers work with different data types.
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
Lecture 3: Getting Started & Input / Output (I/O)
Development Environment
Great way to learn is by example so fire up Visual Studios C (at home make sure you custom install with C++ - no longer default) by Deborah R. Fowler.
C++ Programming: Presentation 1
CHAPTER 2 PART #1 C++ PROGRAM STRUCTURE
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.
Chapter 2 part #1 C++ Program Structure
Beginning C++ Programming
How to Run a Java Program
Welcome to Intro to C/C++ CISC 192
How to Run a Java Program
Download and Installation of code::blocks
Computational Urban Modelling and Simulation
Programs written in C and C++ can run on many different computers
IPC144 Introduction to Programming Using C Week 4 – Lesson 1
Running a Java Program using Blue Jay.
Introduction to Programming - 1
Review of Previous Lesson
Welcome to Intro to C/C++ CISC 192
Chapter 2 part #1 C++ Program Structure
Presentation transcript:

C++ LANGUAGE TUTORIAL LESSON 1 –WRITING YOUR FIRST PROGRAM

Before we can start writing a program we need an integrated development environment which is a software application that provides essential tools for computer programs assist in software development. Essentially it is the software you will use to write and compile your code. For these tutorials we will be using a program called CodeBlocks for such reasons as: Its free Cross platform support for windows, linux and mac Uses a simple design ideal for beginners

To install CodeBlocks follow the steps below: 1.Download CodeBlocks from 2.Open the executional file downloaded to start the installation 3.Follow the onscreen instructions to install CodeBlocks 4.Open code blocks

If you have installed CodeBlocks correctly, when open you should see the same as the screenshot below:

Before we start any coding we need to setup a new project as follows: 1.Select File -> New -> Project. (from the top left corner) 2.Now select “Empty Project” and click “go” on the right 3.Select a title such as “Hello world Program” and a destination and click next, then click finish on the second screen. 4.Select File -> New -> Empty File. (from the top left corner) 5.Choose a name such as “program.cpp” ensuring the extension.cpp is at the end of the file name.

Now that we have our project set up we can start. The first piece of code you need to write is “#include ”. This allows us to link our file with the input/output stream. Meaning we don’t need to rewrite everything our self. #include allows you to include header files so you can add functionality to your program that has already been written by others. is the file your are including. So far your program should look like this:

Semi Colons ; are used in c++ to tell the compiler when a statement has ended. These are essential as missing one will cause your program to not build until you correct the error. All statements in c++ end with a semi colon.

So now we have allowed our self to be able to input and output date however we first need a main function in which to write our code (we will cover functions later) for now all you need to know is that int main() will house the main functionality of your program. Written as Int main() { } All code needs to be placed within the squiggly brackets. Think of them as BEGIN and END the brackets define a block of code. I’m sure much of this may spark a lot of questions these will all be answered in later lessons.

So far you should have:

So now we want to output some text so we write this as “std::cout<<“Hello World”<<std::endl; std::cout is saying we want to output something. Std is a namespace which tells the compiler that cout is contained within the standard library and cout is what allows us to output. “Hello World” is the text we wish to output. Text always needs to be encased within quotation marks. To distinguish it from a variable (covered next lesson). Std::endl is telling the compiler to end the line and start a new one. The arrows << is an insertion operator that inserts the data that follows it to the corresponding stream which in this case is the output stream ; ends the statement

So far you should have:

Any function that is an integer needs to return a number. Int main () is no different so at the end of our code we need to include “return 0”. Returning a value to the operating system allows to check if our program succeeded or not by default 0 will returned however we can change this value with a return statement.

Now that we have finished writing our program we need to build and run it. 1.Click the yellow Cog to build (top of the page) 2.Now press the green play button beside the cog, to run the program You should be presented with:

Below is a video of me writing the program.

One last but very important note is commenting your code. Commenting your code means to explain what is happening. You can add coments in c++ with // or for large comments more than a line using /* comments go here */ This will become more clear as time progresses you will see them in the downloadable files.

Well done you have now created your first c++ program. If you are struggling with anything download you can download the source code with comments, along with the executional file.