1 / 27

ITM 255

ITM 255. Introduction. C++ Environment. GNU C++ Microsoft C++.net. Learning C++. To learn C, C++, C++.net (or any programming language), you must do a lot of programming ! Lectures and Textbooks will help, but you must do it yourself ! Similar to learning to drive a car or motorcycle

Download Presentation

ITM 255

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ITM 255 Introduction

  2. C++ Environment • GNU C++ • Microsoft C++.net

  3. Learning C++ • To learn C, C++, C++.net (or any programming language), you must do a lot of programming ! • Lectures and Textbooks will help, but you must do it yourself ! • Similar to learning to drive a car or motorcycle • Practice, Practice, Practice • Do your own homework - Homework is meant to give you’re the experience to be competent in C++

  4. Learning C++ • Similar to art • We can teach someone to draw but not to be an artist • Programming has a certain amount of art • Fully complete every class lab homework ! • Material is progressive

  5. Object Technology • Objects • Properties (attributes) • Actions (behaviors) • Events that can be responded to • Class • Specifies general format of its objects • Procedural programming • Difficult to reuse • Object-oriented programming • Software reusability • More understandable • Better organized

  6. Introduction to Microsoft .NET • .NET initiative • Allows applications created in different languages to communicate with each other • Web-based applications • Independence from a specific language or platform • Web services • XML • SOAP • Universal data access • synchronization

  7. Introduction to Microsoft .NET

  8. Visual C++ .NET • C++ • Developed by Bjarne Stroustrup in early 1980s • Object-oriented programming • Visual C++ • Microsoft implementation of C++ includes Microsoft’s proprietary extensions • Microsoft Foundation Classes (MFC) • Visual C++ .NET • Visual programming language • Framework Class Library (FCL) • Managed Extensions for C++ (MC++) • Access to new data types provided by .NET Framework • Integrated Development Environment (IDE) • Windows Form designer

  9. .NET Framework and the Common Language Runtime • .NET Framework • Manages and executes applications • Shared Source CLI (Common Language Infrastructure) • Archive of source code provides subset of .NET Framework for Windows XP, FreeBSD operating system and Mac OS X 10.2. • ECMA International CLI standard • Common Language Runtime (CLR) • Executes managed code • Microsoft Intermediate Language (MSIL) • Defines instructions for CLR • Execution-management features • Platform independence • Language interoperability

  10. Style guidelines • Each program will be proceeded with a comment block containing the following information. • Program Name • Author’s Name • Date & version of program • Description of what the program does, • Execution instructions and parameters required for execution. • All variables will be assigned a short descriptive name with the first 16 characters unique and a comment indicating usage. • All programs must comply with the current X.3 C++ Standards • Use three (3) spaces to show the logical flow and separate the body of a control logic structure ( if, else, case) • Enclose ALL objects of a logic structure with curly braces. • No more than one statement per line of a program • Each line of a program must be less than 72 characters • If a statement is split – indent subsequent lines • Use parentheses to force order on all algebraic expressions

  11. Bohem and Jaccapponi • 3 Constructs required for structured programming • Sequence • Selection • Iteration • Flow Chart Symbols for Each Basic Construct • Pseudo Code Review

  12. Lets Write a Short Program • Hello world • Write on sheba.cbu.edu using pico and g++ • Write using C++ .net IDE • Calculator

  13. hello.cpp Standard C++ // Program Name hello // Author’s Name L. Schmitt // Date 1/7/2004 // Version 1.0 // Description This is a first C++ program // Execution run hello from the command line or dos #include <iostream> using namespace std; int main() { cout << "Hello World \n I LOVE C++!\n"; std::cout << "Welcome to C++!\n"; return 0; // indicate that program ended successfully }

  14. hello.cpp C++ .net // Program Name hello // Author’s Name L. Schmitt // Date 1/7/2004 // Version 1.0 // Description This is a first C++.net program // Execution run hello from the command line or dos #include “stdafx.h” using namespace System; int _tmain() { Console::WriteLine(S"Hello World \n I LOVE C++!“); Console::WriteLine(S"Hello Welcome to C++!"; return 0; // indicate that program ended successfully }

  15. Arithmetic Operators • Addition f + 7 • Subtraction f - 7 • Multiplication f * 7 • Division f / 7 • Modulus f % 7 ( remainder)

  16. Arithmetic Operators Precedence • Applied from left to right • Parentheses control the order of operation () • Multiplication Division and Modulus • Addition and Subtraction • What is the value of ? • 3 * 2 - 1 + 4 / 2 % 3

  17. Arithmetic Operators Precedence • Applied from left to right • Parentheses control the order of operation () • Multiplication Division and Modulus • Addition and Subtraction • What is the value of ? • 3 * 2 - 1 + 4 / 2 % 3 = • 6 - 1 + 2 = 7

  18. Equality and Relational Operators • Test of Equality • == IS EQUIVALENT • != IS NOT EQUIVALENT • Relational Operators • > < • >= <= • Assignment • = a = b a getsthe value of b

  19. Write a program that asks the user to enter two numbers, obtains the two numbers from the user and prints the sum, product, difference, and quotient of the two numbers. Enter two integers: 8 22 The sum is 30 The product is 176 The difference is -14 The quotient is 0

  20. 1 // Exercise 1.23 Solution 2 #include <iostream> 3 4 using std::cout; 5 using std::endl; 6 using std::cin; 7 8 int main() 9 { 10 int num1, num2; // declare variables 11 12 cout << "Enter two integers: "; // prompt user 13 cin >> num1 >> num2; // read values from keyboard 14 15 // output the results 16 cout << "The sum is " << num1 + num2 17 << "\nThe product is " << num1 * num2 18 << "\nThe difference is " << num1 - num2 19 << "\nThe quotient is " << num1 / num2 << endl; 20 21 return 0; // indicate successful termination 22 }

  21. In Class AssignmentWrite a simple program that will • Accept 2 numbers from the keyboard • output the larger number • output the smaller number • output the sum of the numbers • output the difference of the numbers • output the product of the numbers • output larger/smaller and remainder

  22. * Fig. 2.5: fig02_05.c Addition program */ #include <stdio.h> int main() { int integer1, integer2, sum; /* declaration */ printf( "Enter first integer\n" ); /* prompt */ scanf( "%d", &integer1 ); /* read an integer */ printf( "Enter second integer\n" ); /* prompt */ scanf( "%d", &integer2 ); /* read an integer */ sum = integer1 + integer2; /* assignment of sum */ printf( "Sum is %d\n", sum ); /* print sum */ return 0; /* indicate that program ended successfully */ }}

  23. /* Fig. 2.13: fig02_13.c Using if statements, relational operators, and equality operators */ #include <stdio.h> main() { int num1, num2; printf( "Enter two integers, and I will tell you\n" ); printf( "the relationships they satisfy: " ); scanf( "%d%d", &num1, &num2 ); /* read two integers */ if ( num1 == num2 ) printf( "%d is equal to %d\n", num1, num2 ); if ( num1 != num2 ) printf( " %d is not equal to %d\n ", num1, num2 ); if ( num1 < num2 ) printf( "%d is less than %d\n", num1, num2 ); if ( num1 > num2 ) printf( "%d is greater than %d\n", num1, num2 ); if ( num1 <= num2 ) printf( "%d is less than or equal to %d\n", num1, num2 ); if ( num1 >= num2 ) printf( "%d is greater than or equal to %d\n", num1, num2 ); return 0; /* indicate program ended successfully */ }

More Related