all 300/400 level cs major courses tutoring location: sec 3433 sign up or walk-in introduction2-1

18
All 300/400 Level CS Major Courses Tutoring http://cs.ua.edu/undergraduate/ tutoring/ Location: SEC 3433 Sign up or walk-in Introduction 2-1

Upload: emil-bruce

Post on 29-Dec-2015

215 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: All 300/400 Level CS Major Courses Tutoring  Location: SEC 3433 Sign up or walk-in Introduction2-1

All 300/400 Level CS Major Courses

• Tutoringhttp://cs.ua.edu/undergraduate/tutoring/

• Location: SEC 3433• Sign up or walk-in

Introduction 2-1

Page 2: All 300/400 Level CS Major Courses Tutoring  Location: SEC 3433 Sign up or walk-in Introduction2-1

Language and IDE

• C++/CLI language and .NET framework

• Examples in Microsoft Visual Studio 2012

Page 3: All 300/400 Level CS Major Courses Tutoring  Location: SEC 3433 Sign up or walk-in Introduction2-1

Compiled Languages

Compiler(Including

Linker)hello.cpp

(high level)hello.exe(machine)

ResultExecutorhello.exe

Page 4: All 300/400 Level CS Major Courses Tutoring  Location: SEC 3433 Sign up or walk-in Introduction2-1

Interpreted Languages

Interpreterhello.bas Result

Page 5: All 300/400 Level CS Major Courses Tutoring  Location: SEC 3433 Sign up or walk-in Introduction2-1

Hybrid Compiler-Interpreter

Interpreter

Source code

Result

CompilerIntermediate language code

Page 6: All 300/400 Level CS Major Courses Tutoring  Location: SEC 3433 Sign up or walk-in Introduction2-1

C++/CLI

CLR

C++/CLISource Code

Result

C++/CLI compiler CIL Bytecode

This applies to C# and VB .NET too.

CLR = Common Language Runtime

CIL = C++ Intermediate Language

Page 7: All 300/400 Level CS Major Courses Tutoring  Location: SEC 3433 Sign up or walk-in Introduction2-1

About C++\CLI • C++ (.h, .cpp, complied)

• C++/CLI (compiled to MSIL (Microsoft

Intermediate Language), not machine code)(not interpreted at runtime)

• C++ vs. C++/CLI– Unmanaged code vs. managed code

• Managed code: memory management, code access security, multi-language integration

– Garbage collection

Page 8: All 300/400 Level CS Major Courses Tutoring  Location: SEC 3433 Sign up or walk-in Introduction2-1

.NET

– Application development technologies– .NET base class library– Common Language Runtime (above OS)

Page 9: All 300/400 Level CS Major Courses Tutoring  Location: SEC 3433 Sign up or walk-in Introduction2-1

.NET Advantages• Language natural … MSIL

– Many non-MS languages can use base class library

– Common Type System (CTS)

– Common Language Specification (CLS)

• Minimum subset of CTS for all the .NET compatible languages

• Platform independent … CLR– Port .NET Framework to non-Windows platform w/o recompiling

– JIT: Just-In-Time Compilation

– A JIT compiler translates bytecode into the native machine language.

Page 10: All 300/400 Level CS Major Courses Tutoring  Location: SEC 3433 Sign up or walk-in Introduction2-1

IDE (Integrated development environment)

• Microsoft Visual Studio for C++

Page 11: All 300/400 Level CS Major Courses Tutoring  Location: SEC 3433 Sign up or walk-in Introduction2-1

Obtain Microsoft Visual Studio 2012(either Professional, or Ultimate)

Visual Studio 2012 only:

•any student at UA at no cost.

•http://oit.ua.edu/oit/services/software-licensing/dreamspark-standard/ and scroll to the very end (click on the “WebStore” link in “Obtaining Software”

Page 12: All 300/400 Level CS Major Courses Tutoring  Location: SEC 3433 Sign up or walk-in Introduction2-1

Obtain Windows, Microsoft Visual Studio 2012

(either Professional, or Ultimate)

OIT resources for licensed copies •access software through DreamSpark

– STEM departments: DreamSpark Premium •http://oit.ua.edu/oit/services/software-licensing/dreamspark-standard/

•https://www.dreamspark.com/Institution/Subscription.aspx

•No cost to eligible students•Get help:

– OIT service desk

– CS : Jeremy LaGrone, jlagrone at cs ua edu

Page 13: All 300/400 Level CS Major Courses Tutoring  Location: SEC 3433 Sign up or walk-in Introduction2-1

Examples• How to use Microsoft Visual Studio 2012

• Assignment: within next two weeks– Download and install Microsoft Visual Studio

2012. – If needed, Windows as well.– Use Visual Studio to create a project of CLR

Console Application after this class • Can use your current or later assignments

Page 14: All 300/400 Level CS Major Courses Tutoring  Location: SEC 3433 Sign up or walk-in Introduction2-1

• Create a CLR Console Application– Start Microsoft Visual Studio 2012

– Create a new project by selecting from the menu bar "FILE"-> "New"->"Project". In the "New Project" dialog box, select "Visual C++" under "Installed Templates" and select "CLR Console Application" as the project template. Enter C:\CS351\Projects (or any directory designated for keeping your CS351 projects) in the "Location" field, and First (or any project name) in the "Name" filed. It is better to uncheck "Create directory for solution".

– Add code to the project.

– Build.

– Execute.

Page 15: All 300/400 Level CS Major Courses Tutoring  Location: SEC 3433 Sign up or walk-in Introduction2-1

backups

Page 16: All 300/400 Level CS Major Courses Tutoring  Location: SEC 3433 Sign up or walk-in Introduction2-1

Examples

• Quadratic Equation: ax2+bx+c=0

• Discriminant: ∆=b2-4ac

• Two roots: x1=

x2=

a

acbb

2

42

a

acbb

2

42

Page 17: All 300/400 Level CS Major Courses Tutoring  Location: SEC 3433 Sign up or walk-in Introduction2-1

• // Quadratic.cpp : main project file. 

• #include "stdafx.h"

• using namespace System;

• int main(array<System::String ^> ^args)

• {

• double a, b, c;

• Console::Write(L"Enter the quadratic coefficiet(a): ");

• a = Double::Parse(Console::ReadLine());

• Console::Write(L"Enter the linear coefficnet(b): ");

• b = Double::Parse(Console::ReadLine());

• Console::Write(L"Enter the constant term(c): ");

• c = Double::Parse(Console::ReadLine());

•  

• double discriminant;

• discriminant = b*b-4*a*c;

• double x1 = (-b+Math::Sqrt(discriminant))/(2*a);

• double x2 = (-b-Math::Sqrt(discriminant))/(2*a);

•  

• Console::WriteLine(L"Two roots are " + x1 + " and " + x2);

• return 0;

• }

Page 18: All 300/400 Level CS Major Courses Tutoring  Location: SEC 3433 Sign up or walk-in Introduction2-1

Play with code

• 1. Console application – Output more

– Read so to pause • Console::Write(L"Enter the constant term(terminate): ");

• Int c = Double::Parse(Console::ReadLine());

• Console::Write(L"Verify");

• Boolean y = Double::Parse(Console::ReadLine());

• 2. Windows Form Application– Use different form name