140 likes | 297 Views
CSE 1020 - Lab 4. TA: Song Huang. Download Microsoft Visual Studio 2010. Create an account on the UNT Microsoft Software download website: https://e5.onthehub.com/WebStore/Security/Signin.aspx?ws=adbe7b34-809b-e011-969d-0030487d8897&vsro=8&action=signout&JSEnabled=1.
E N D
CSE 1020 - Lab 4 TA: Song Huang
Download Microsoft Visual Studio 2010 • Create an account on the UNT Microsoft Software download website: • https://e5.onthehub.com/WebStore/Security/Signin.aspx?ws=adbe7b34-809b-e011-969d-0030487d8897&vsro=8&action=signout&JSEnabled=1
Create a Project With Visual Studio 2010 • Start Menu -> All Program -> Microsoft Visual Studio 2010 • Select “Microsoft Visual Studio 2010” (-> Visual C++ in the dialog if this is your first time) • File -> New -> Projects • Select “Visual C++” on the left area of the dialog, Select “Empty Project” in the middle, and give the name of the project at the bottom.
Create a Source File for that Project • Find out the “Solution Explorer”: top menu “View” -> “Solution Explorer” • Right Click the folder “Source File”, “Add” -> “New Item”, select “C++ File (.cpp)” , give it a name at the bottom of the dialog, and then click add.
When is the Source File that you create • C:\Users\YourAccount\Documents\Visual Studio 2010\Projects
When You are using Visual Studio • using namespace std; (after #include <iostream>) • system(“pause”); (delete this statement when you copy your program into your web compiler) • use “#include <string>” when you have string type variable in your program.
Important Components in the Programs • Programs are consisted of: • Selection Branches (select the procedures) • Loops (repeat operations)
Selection Branches • if(conditions) { operation 1; operation 2; ……… }
Selection Branches Importance: • There is no “;”, after the conditions, usually, we use “;” to close a statement if you finish the operation. • Use logical operator to connect multiple conditions, for example: “&&”, “||”… • Use bracket { } to include the operations
Selection Branches • if(conditions){ operations; } else if(conditions){ operations; } else{ }
Selection Branches • if(conditions){ operations; } if(conditions){ operations; } if(conditions){ operations; }
Selection Branches - Example • int a = 9; • if(a > 7){ cout << a << endl; } else if(a > 6){ cout << a << endl; } else if(a > 5){ cout << a << endl; }
Selection Branches - Example • int a = 9; • if(a > 7){ cout << a << endl; } if(a > 6){ cout << a << endl; } if(a > 5){ cout << a << endl; }