A1 Visual C++.NET Intro Programming in C++ Computer Science Dept Va Tech August, 2002 ©1995-2002 Barnette ND & McQuain WD 1 Quick Introduction The following.

Slides:



Advertisements
Similar presentations
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Advertisements

CS0004: Introduction to Programming Visual Studio 2010 and Controls.
Visual Basic 2010 How to Program. © by Pearson Education, Inc. All Rights Reserved.2.
Visual Basic 2010 How to Program Reference: Instructor: Maysoon Bin Duwais slides Visual Basic 2010 how to program by Deitel © by Pearson Education,
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.
Customizing Word Microsoft Office Word 2007 Illustrated Complete.
1 CA202 Spreadsheet Application Creating Dynamic Lists with PivotTables Lecture # 9.
1 Lab Session-I CSIT120 Spring2001 Using Windows Using An Editor Using Visual C++ Using Compiler Writing and Running Programs Lab-1 continues (Session.
SUNY Morrisville-Norwich Campus-Week 12 CITA 130 Advanced Computer Applications II Spring 2005 Prof. Tom Smith.
Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.
Creating a Console Application with Visual Studio
1 ENG236: ENG236: C++ Programming Environment (2) Rocky K. C. Chang THE HONG KONG POLYTECHNIC UNIVERSITY.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering.
XP New Perspectives on Microsoft Access 2002 Tutorial 41 Microsoft Access 2002 Tutorial 4 – Creating Forms and Reports.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 2 - Welcome Application: Introduction to C++
Computing IV Visual C Introduction with OpenCV Example Xinwen Fu.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 11 1 Microsoft Office Access 2003 Tutorial 11 – Using and Writing Visual Basic for Applications.
IT 211 Project Integration and Deployment Lab #11.
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.
IE 411/511: Visual Programming for Industrial Applications
CS161 Topic #21 CS161 Introduction to Computer Science Topic #2.
Intro to C++. Getting Started with Microsoft Visual Studios Open Microsoft Visual Studios 2010 Click on file Click on New Project Choose Visual C++ on.
Computer Programming for Engineers Introduction to Programming in C Language on Visual C Platform Intro. Comp. Prog. C-Language1.
CS 114 – Class 02 Topics  Computer programs  Using the compiler Assignments  Read pages for Thursday.  We will go to the lab on Thursday.
CPS120: Introduction to Computer Science Compiling Your Programs Using Visual C++
Productivity Programs Common Features and Commands.
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
Microsoft Visual Basic 2010 CHAPTER THREE Program Design and Coding.
Lecture 6: Computer Languages. Programming Environments (IDE) COS120 Software Development Using C++ AUBG, COS dept.
Computer Science I How to Configure Visual Studio.NET 2003 for C++ Colin Goble.
Our Environment We will exercise on Microsoft Visual C++ v.6 We will exercise on Microsoft Visual C++ v.6 because that is what we have in the univ. because.
Active-HDL Interfaces Building VHPI Applications C Compilation Course 9.
9. Types Intro Programming in C++ Computer Science Dept Va Tech August, 2002 © Barnette ND & McQuain WD 1 Data Types data type:a collection of.
Unit 1: Java and Eclipse The Eclipse Development Environment.
Using Microsoft Visual Studio 2005 Original by Suma Rao Revised by John G. McMahon ( 9/6/2008 )
TUTORIAL 9 INSTRUCTOR: HANIF ULLAH ID: OFFICE #: 2029 DATE: 22/04/2012 Introduction to MS Project 2007.
Using Microsoft Visual Studio C++ Express 2005 Name: Dr Ju Wang Ashwin Belle Course Resource:
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 8 Debugging, Creating Executable Files, and Distributing a Windows Application.
1 C++ Programming Basics Chapter 1 Lecture CSIS 10A.
CS Class 05 Topics  Selection: switch statement Announcements  Read pages 74-83, ,
2. Program Development Intro Programming in C++ Computer Science Dept Va Tech August 2001 ©2001 Barnette ND & McQuain WD 1 Top-Down Design:A solution method.
CREATING A DOCUMENT Using MS Word Presented by Dr. Ennis-Cole.
1 Debugging and Syntax Errors in C++. 2 Debugging – a process of finding and fixing bugs (errors or mistakes) in a computer program.
Using This PowerPoint This PowerPoint presentation assumes your Computer Science teacher has provided you with the InstallingJava folder, which contains.
An Introduction to Forms. The Major Steps of a MicroSoft Access Database  Tables  Queries  Forms  Macros  Reports  Modules On our road map, we are.
This is how you invoke the Microsoft Visual Studio 2010 Software. All Programs >> Microsoft Visual Studio 2010.
Chapter 3 I Need a Tour Guide (Introduction to Visual Basic 2010) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Lecture Set 2 Part A: Creating an Application with Visual Studio – Solutions, Projects, Files 8/10/ :35 PM.
1 Getting Started with C++ Part 1 Windows. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Microsoft.
Compilers and Interpreters
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
Word and the Writing Process. To create a document 1.On the Start menu, point to Programs, and then click Microsoft Word. A new document opens in Normal.
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
Software Engineering Algorithms, Compilers, & Lifecycle.
A05. List Debug Intro Data Structures & SE Computer Science Dept Va Tech Aug., 2001 © Barnette ND, McQuain WD 1 MSVC IDE Debugger List Tracing.
Tutorial 1 Writing Your First C++ Program CSC1110C Introduction to Computer Programming By Paul Pun Acknowledgement: Special thanks to Dr. Michael Fung.
DEVRY CIS 170 C I L AB 1 OF 7 G ETTING S TARTED Check this A+ tutorial guideline at
DEVRY CIS 170 C I L AB 2 OF 7 D ECISIONS Check this A+ tutorial guideline at decisions For.
Lab 1 Introduction to C++.
1. Open Visual Studio 2008.
Welcome to Intro to C/C++ CISC 192
Lab 1 Introduction to C++.
Here is how you find MS Visual C on the Engineering
Double click Microsoft Visual Studio 2010 on the Computer Desktop
Creating the First Program
Welcome to Intro to C/C++ CISC 192
Presentation transcript:

A1 Visual C++.NET Intro Programming in C++ Computer Science Dept Va Tech August, 2002 © Barnette ND & McQuain WD 1 Quick Introduction The following pages provide a quick tutorial on using Microsoft Visual C++.NET to produce a small project. There are substantial changes from version 6.0 of Visual Studio. The following discussion is based on an actual session using the Visual C++.NET Developer’s Studio. The menu selections and options illustrated here do not conform to earlier versions of Visual C++. Please note the disclaimer in the front of these notes regarding compiler selection. MS Visual C++.NET Introduction

A1 Visual C++.NET Intro Programming in C++ Computer Science Dept Va Tech August, 2002 © Barnette ND & McQuain WD 2 Getting Started: MS Visual C++.NET Start Visual C++.NET from the menu: The main window will look something like:

A1 Visual C++.NET Intro Programming in C++ Computer Science Dept Va Tech August, 2002 © Barnette ND & McQuain WD 3 Creating a New Project Before you can begin coding, you must create a new Project. To do so, go to the File menu and select New… and then Project: You should see a dialog box: In the Template window, select Win32 Project. In the Name field, type the name you want to give the project. Here, we call it DayOfTheWeek. Also pick the location you want for your project files.

A1 Visual C++.NET Intro Programming in C++ Computer Science Dept Va Tech August, 2002 © Barnette ND & McQuain WD 4 Win32 Application Wizard After clicking Ok from the New project dialog window you will be presented with the Win32 Application Wizard dialog window. Click on Application Settings.

A1 Visual C++.NET Intro Programming in C++ Computer Science Dept Va Tech August, 2002 © Barnette ND & McQuain WD 5 Win32 Application Settings For all the assignments in CS 1044, you must select "Console application" and "Empty project": Click "Finish". If you get either of these settings wrong, you will not be able to complete your assignment.

A1 Visual C++.NET Intro Programming in C++ Computer Science Dept Va Tech August, 2002 © Barnette ND & McQuain WD 6 The Project Workspace You should now see the main Visual C++.NET window shown below: The window panel at the right is called the Solution Explorer. It's not of much use in CS 1044, but it shows a tree diagram that can display names of all the files in your project. You can hide the panel by clicking its close button if you prefer not to see it.

A1 Visual C++.NET Intro Programming in C++ Computer Science Dept Va Tech August, 2002 © Barnette ND & McQuain WD 7 Creating a Code File Now that you have created a Project, you need to add source code to it. To do so, go to the File menu and select Add New Item. (If you had already typed in your C++ source code file, you'd select Add Existing Item.) In the dialog box, select the Template C++ file: And enter the name you want to give the file. Click "Open".

A1 Visual C++.NET Intro Programming in C++ Computer Science Dept Va Tech August, 2002 © Barnette ND & McQuain WD 8 Creating a Code File (continued) The main Visual C++.NET window now shows an empty edit box in which you will type the C++ language statements for your program:

A1 Visual C++.NET Intro Programming in C++ Computer Science Dept Va Tech August, 2002 © Barnette ND & McQuain WD 9 C++ Code for DayOfTheWeek Now in the edit window that just appeared type in the following C++ source code (exactly as it is given): #include using namespace std; int main() //Find the Day of the Week for a Date { int mon, day, year; cout << "Enter a date for which you wish to know" << endl; cout << "the day of the week (MM DD YYYY)? "; cin > day >> year; if (year < 1752) cout << "Only Gregorian dates accepted, sorry " << endl; else { if (month < 3) { //Jan & Feb = 13 & 14 preceding year month += 12; year -= 1; { // end if

A1 Visual C++.NET Intro Programming in C++ Computer Science Dept Va Tech August, 2002 © Barnette ND & McQuain WD 10 C++ Code (continued) weekDay = (day + 2*month + 3*(month+1)/5 + year + year/4 - year/100 + year/ ) % 7; if (month > 12) { //reset Jan & Feb month -= 12; year += 1 ; } // end if cout << month << "/" < day << "/" << year << " falls on "; switch (weekday) { case 0: cout << "Sunday" << endl; break; case 1: cout << "Monday" << endl; break; case 2: cout << "Tuesday" << endl; break; case 3: cout << "Wednesday" << endl; break; case 4: cout << "Thursday" << endl; break; case 5: cout << "Friday" << endl; break; case 6: cout << "Saturday" << endl; break; } // end switch } // end else return 0; } // end main Be sure to save the file occasionally as you work.

A1 Visual C++.NET Intro Programming in C++ Computer Science Dept Va Tech August, 2002 © Barnette ND & McQuain WD 11 Code Editing Window Now that you have entered all of your source code, you should have a window that looks like:

A1 Visual C++.NET Intro Programming in C++ Computer Science Dept Va Tech August, 2002 © Barnette ND & McQuain WD 12 Building an Executable Before your program can be executed ("run"), the C++ language code you just typed in must be translated into a language the underlying computer hardware can understand. This is easily done by using the Visual C++.NET environment, via the toolbars or menus. As discussed elsewhere in these notes, the translation process involves two main phases: Compilation checks your C++ language code for grammatical correctness and partially translates it into machine language. Linking checks the results of the compilation phase for other errors, and completes the translation, producing a new file called an executable image ("exe") file. The two phases together are often referred to as "building" the executable.

A1 Visual C++.NET Intro Programming in C++ Computer Science Dept Va Tech August, 2002 © Barnette ND & McQuain WD 13 Building in Visual C++.NET You can attempt to build an executable for your Project by selecting the Build option from the Build menu: It is entirely possible that the compilation phase will find errors in your C++ code. In fact, if you typed the given example code exactly as given, errors are guaranteed. The compiler will generate error messages describing the things it found wrong in your C++ code. Those messages will be displayed in the Output panel:

A1 Visual C++.NET Intro Programming in C++ Computer Science Dept Va Tech August, 2002 © Barnette ND & McQuain WD 14 Interpreting Error Messages The error messages generated by the compiler attempt to describe some grammatical (syntax) error in your C++ language code. Understanding what an error message means requires that you have some understanding of the grammar of the C++ language. In many cases, the meaning is very clear. In others, the message may be phrased in a way that only a "language lawyer" would understand. It gets better with experience.

A1 Visual C++.NET Intro Programming in C++ Computer Science Dept Va Tech August, 2002 © Barnette ND & McQuain WD 15 Finding the Location of an Error Notice the compiler error messages in the lower window. Double click on an error message, and the line* with the error will be indicated in the code edit window: * Well, more or less…

A1 Visual C++.NET Intro Programming in C++ Computer Science Dept Va Tech August, 2002 © Barnette ND & McQuain WD 16 Correcting Errors Once you have determined the cause of the error message, you merely edit your C++ language code to correct the problem. You might want to attempt to correct several errors at once, or attempt to re-build after each change. It is important to consider the error messages in the order they are generated. In many cases, one mistake in your code may produce an avalanche of error messages. In our case, the first error is fairly simple. C++ grammar requires that every identifier (variable name) must be formally declared before it is used. In this case, we have a spelling error, but it is in the declaration a few lines up from the flagged line:

A1 Visual C++.NET Intro Programming in C++ Computer Science Dept Va Tech August, 2002 © Barnette ND & McQuain WD 17 Error List In case you can't figure out the other errors here are the corrections: Line 10:change the > Line 21:add a declaration for the name weekDay, right after the declaration for month Line 29:change the < to << Line 30:change the spelling of "weekday" to match the capitalization used above Line 20:change '{' to '}' Note that if you didn't format your code like the notes, then the line numbers above won't match.

A1 Visual C++.NET Intro Programming in C++ Computer Science Dept Va Tech August, 2002 © Barnette ND & McQuain WD 18 Clean Compilation Once you have corrected all the errors, the Output panel will show the message below, indicating "0 errors" during compiling and linking: This does NOT mean your program is logically correct, just that the grammar is correct.

A1 Visual C++.NET Intro Programming in C++ Computer Science Dept Va Tech August, 2002 © Barnette ND & McQuain WD 19 Executing Your Program Now that your code has been compiled into an executable, it is ready to be executed. You can do so by pressing or going to the Debug menu and selecting Start without debugging: Now you should see a DOS prompt with the program running: