1 / 32

CSE1320-002-Fall 2014 Basics

CSE1320-002-Fall 2014 Basics. Dr. Sajib Datta CSE@UTA Aug 27, 2014. Course Details. The website is up. Course lectures will be uploaded there Check regularly for assignments and update. Programming Platform.

lois-duke
Download Presentation

CSE1320-002-Fall 2014 Basics

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. CSE1320-002-Fall 2014Basics Dr. SajibDatta CSE@UTA Aug 27, 2014

  2. Course Details • The website is up. • Course lectures will be uploaded there • Check regularly for assignments and update

  3. Programming Platform • For omega access, each student that needs to have access to it will need to contact the help desk and request it. The best way is to call them at 817-272-2208 and ask to have omega access added to your NetID account. • Visual Studio download information: • http://www.uta.edu/oit/cs/software/microsoft/visual-studio-2010/index.php

  4. Using Omega Server • A Linux server • Get an account! • http://www.uta.edu/oit/cs/web/omega-web.php • Provides C, C++, Lisp, Prolog, Cobol, and Fortran language compilers • Connect using SSH http://www.uta.edu/oit/cs/files/sftp/ssh/index.php

  5. Using Omega • Windows users: download SSH client from OIT • http://www.uta.edu/oit/cs/unix/ssh/Secure-Shell-Client.php

  6. Connecting to Omega

  7. Provide Login Information • omega.uta.edu

  8. Provide Password

  9. File Transfer

  10. Omega Terminal

  11. From MAC/Linux • Applications -> Utilities -> Terminal • Login: • $ ssh your_netID@omega.uta.edu • Logout: • $ logout<Return>

  12. Some UNIX commands • ls : displays the files in a specified directory • [vxg4212@omega ~]$ ls • rm: delete a file • [vxg4212@omega ~]$ rmfile_name • cp: copy files (caution, will replace if file already exists) [vxg4212@omega ~]$ cpsource_filedestination_file

  13. Some UNIX commands • mv: rename files • [vxg4212@omega ~]$ mv old_filenamenew_filename • [vxg4212@omega ~]$ mv old_filename directory/new_name

  14. More… • pwd -> print the current (working) directory • cd -> change directory • cd .. ->go up one level • mkdir -> make a new directory • rmdir -> remove a directory • Note: Commands can have options. Use man command_statement to get full details

  15. Working with VI • vi editor • [vxg4212@omega ~]$ vi file_name.extension • Two modes: Command mode and Insert mode

  16. Working with VI • Insert mode: entered text is inserted into the file • Hit i to get into insert mode • Hit Esc to get out of insert mode • Whole lot of options available in insert mode! http://www.cs.colostate.edu/helpdocs/vi.html

  17. Copy to/from remote machine • Local computer to a remote computer scpfile_nameuser_name@server:/home/user_name/ • Remote server to your local computer scpuser_name@server:/home/user_name/file_name/home/local-user_name/file_name

  18. C compiler • gcc : compile a C program • vxg4212@omega ~]$ gcc -o my_outprogram_file.c • Run the compiled program • vxg4212@omega ~]$ my_out<Return>

  19. Introduction to C • Variables, Statements, Operators, Expressions

  20. Basics • Storing information - Variables • Statements - Declaration, Assignment, Function • Making decisions – Conditionals intnum; num = 51; if (num > 25) printf(“a large class. \n”); else printf(“a small class. \n”); • Repeating certain tasks – Loops • Print “CSE 1311003” 1000 times Variable declaration Assigning a value to the variable conditional Print function conditional Print function

  21. Variables • A variable is a symbolic name used to represent some information – data • A variable is associated with a type, data storage location, its content which can be changed in running the program

  22. Variables • C requires the programmer to specify the type of variable. Some examples are: • int– used for integers, • A number with no fractional part • Never with a decimal point • 3, 14, -13, 7 • double– used for floating point numbers • A real number including numbers between the integers • 0.5, 1.234 • char– used for characters, e.g., ‘A’, ‘7’, ‘?’

  23. Naming a variable • Lowercase letters, uppercase letters, digits, and underscore • First character must be a letter or an underscore • Not key words

  24. Variables • Declare a variable: • intweight; • intheight; • intweight, height; • Different variable types use different amounts of memory /* reports the amount of memory occupied by an int on this hardware */ printf("an int takes %d bytes of memory\n",sizeof(int));

  25. Variables • Declare a variable • intheight; [note that no value is still assigned] • Assign a variable a value • height = 5; • Define - Declare & Initialize • intheight = 5; • char name = ‘a’; • double marks= 90.3;

  26. Variables • Print a variable • printf(“%d”, num); - format specifier, variable • Number matching - the number of specifiers is equal to the number of variables • Type matching • %d for int • %lf for double • %c for char • printf can be used just to print text • printf(“this is just a text”);

  27. Statements • A C program consists of statements • Some types of statements: • declaration statements • Assignment statements • Function calls • Control statements • Each statement is terminated by a semicolon. • Control statement can change the program flow.

  28. Declaration • Declaration statements are when we declare variables for use. void main() { int a; …… }

  29. Assignment • Have a left side and a right side. • The right side: • a single value, a complicated expression, or a function call • ultimately reduce to a single value, which is then assigned to the variable named on the left side. • Example: • intnum;[declaration] • num= 1; • num= num + 10; • num= num + 2;[what is the final value of num?]

  30. Operators • The basic operators that you have in math are also available in C: • +, • -, • *, • /, • = • WARNING: Difference between operators in C and their math use is integer division. • The fraction resulting is truncated in integer division • integer = integer / integer • Example: • int a = 7, b = 5; • intanswer; • answer = a / b;

  31. Think! float a = 7.1, b = 5.2; intanswer; answer = a / b;

More Related