1. The Mac Environment in Sierra Hall 1242

Size: px
Start display at page:

Download "1. The Mac Environment in Sierra Hall 1242"

Transcription

1 Wednesday, August 26, 2015 Lab Notes Topics for today The Mac Environment C (and Unix) Notes on C Part 1 Program 1 1. The Mac Environment in Sierra Hall 1242 a. Turning on the Mac If the Mac is in sleep mode you can just jiggle the mouse to wake it up. If it is powered off, press for a second or so the button found on the left side (looking from the front) of the back of the monitor.. b. Logging in Use your Dolphin username and password c. Logging off Select log off under the Apple menu. d. Saving files Files you create on one Mac in the lab will not be available on another unless you save them to a drive you can access from a second Mac (e.g. Google Drive, Dropbox, portable flash drive). Your Z drive should be accessible as /Volumes/students$/first.lastnnn e.g. /Volumes/students$/richard.rush123 A flash drive should show up as /Volumes/drivename You can save a file from your current directory to the Z drive as follows cp filename /Volumes/students$/first.lastnnn Comp 162 Lab Notes Page 1 of 10 August 26, 2015

2 2. C (and Unix) To create and run C programs you can use the Unix environment that underlies ios on a Mac accessible using Terminal ios environment To set up a Unix terminal go to Applications Utilities Terminal Unix is a command line environment. The command prompt is something like e.g. SH1242-nn:~directory user$ SH : Printers Peter.Smith$ Here are some useful commands; note that Unix is case sensitive. General man command exit script filename prints the manual page for the command end terminal session save listing of terminal session to file (end saving with exit) Directories pwd cd d cd cd.. ls ls l ls l filename mkdir d rmdir d gives name of current (working) directory change to directory d change to home directory change to parent directory list contents of current directory list contents in more detail (use man ls to see more options) list directory entry for file make subdirectory d remove subdirectory d (must be empty) If you are connected to Google Drive or Dropbox you will see subdirectories in your home directory. Files you save in the subdirectories will be available on other systems you use. File Manipulation cat filename more filename mv f1 f2 list contents of file list contents of file one screen at a time rename file from f1 to f2 Comp 162 Lab Notes Page 2 of 10 August 26, 2015

3 rm filename cp f1 f2 head n f tail n f pico filename ed filename vi filename emacs delete (remove) file make a copy of file f1, call it f2 list first n lines of file list last n lines of file Simple screen editor (recommended for beginners) Line editor Screen editor Complex, powerful screen editor Languages (where installed) gcc filename.c g++ filename.cc C compiler C++ compiler Editors Almost every Unix system will have vi and emacs. The simplest editor for you to use is probably pico. A test program. Using the editor of your choice, create a file (one.c) containing the following text which is the C version of the Pep/8 program we saw earlier. int main() printf( hello world\n ); Now compile it by issuing the command gcc one.c If successful, the compilation will produce a file (a.out) containing a translation of the program Now run the assembled output./a.out When you have finished using Unix, use exit to end the terminal session then exit the Terminal application in the pull-down menu. Comp 162 Lab Notes Page 3 of 10 August 26, 2015

4 Notes on C part 1 Introduction The purpose of this document describing the C language is to give you a brief introduction to its syntax and features. C is particularly suitable for some of the low-level operations that used to be done in assembly language. The goal is to give you a reading knowledge of the C language, i.e., you should be able to look at a C program and figure out what it does. In Comp 162 we will illustrate some mappings between high-level and low-level languages using C and Pep/8 assembly code. The course Notes page contains links to source files for the examples in this and Part 2 numbered 1 through 20. I have found the following book to be a good introduction to C. A book on C: programming in C Al Kelley and Ira Pohl Addison-Wesley (4 th edition, 1998) There are free C books and notes on the web see links on the course page. C is relatively simple and can be compiled into efficient assembly language. However, it is powerful and C programs can be cryptic Example 1 Here is a complete C program to print hello world (without the quotes). int main() printf("hello world\n"); Notes on Example 1 1. The #include line is a directive to the pre-processor to include the contents of system file stdio.h at this point. The file contains information needed to enable us to use the printf output function. 2. The main program is always a function (subprogram) called main. In many environments it returns an integer. 3. C uses braces to group statements much as some other languages use begin... end. 4. The printf function prints the string we give it. It is actually much more general than in this example. 5. The \n notation in the string represents the newline character. Comp 162 Lab Notes Page 4 of 10 August 26, 2015

5 Many C compilers expects files containing C source code to have the.c extension. Assume that the program above is stored in file hello.c on a typical Unix/Linux system. To compile our file we give the following command: gcc hello.c The program has no syntax errors so our compilation results in an object program called hello. We run our object file by giving the command The output is hello world a.out or./a.out Example 2 The second program introduces variables and shows some input/output. /* reads two integers and outputs their average */ main() int one, two; float average; printf("input two integers: "); scanf("%d %d",&one,&two); average = ( (float)one + (float)two ) / 2.0; printf("the average of %d and %d is %6.1f\n",one,two,average); Notes on Example 2 1. text between /* and */ is commentary. Some compilers also ignore text between // and the end of the line. 2. int (integer) and float (single-precision reals) are built-in types. 3. scanf is an input routine. The first parameter describes the format of the input; the %d designates a decimal integer. Other parameters are addresses (note the &) of variables that the data is read into. 4. The notation (type) is a cast. It forces the following expression into the particular type. Here we use (float) to get real equivalents of the input integers so we get a correct average of two integers. 5. In the second call of printf, note how the first parameter can be a mixture of text and format specifications. Values in the remaining parameters are output in the corresponding formats. The format %6.1f indicates that we would like the value of the average output as a float with a total of 6 characters and one decimal place. Comp 162 Lab Notes Page 5 of 10 August 26, 2015

6 Typical output Input two integers: The average of 19 and 102 is 60.5 Example 3 Conditionals Here is a program that inputs a year and determines whether or not it is a leap year. /* determine whether input year is a leap year */ main() int year; printf("input year: "); scanf("%d",&year); if (year%4!= 0) printf("%d is not a leap year",year); /* e.g */ else if (year%100!= 0) printf("%d is a leap year",year); /* e.g */ else if (year%400!= 0) printf("%d is not a leap year",year); /* e.g */ else printf("%d is a leap year",year); /* e.g */ Notes on Example 3 1. The % operator yields the remainder when the left operand is divided by the right; i.e., it is the modulo operator 2. The condition tested by the if statement is always enclosed in parentheses. 3. If we wished to have multiple statements in either branch of the if statements we would group them with parentheses, thus: if (condition) s1; s2; s3; else s4; s5; 4. The relational operators are: < <= >= >!= (not equals) and == (equals). If you use = instead of == the compiler will probably not complain! For example, suppose we wished to branch according to whether variable d contains 5 but instead write the following: if (d=5) A; else B; the effect is to assign 5 to d. The numeric value of the assignment (5) is interpreted as true (zero is false, non-zero is true) so regardless of the current value of d, action A is performed! Comp 162 Lab Notes Page 6 of 10 August 26, 2015

7 Example 4 Many languages have a facility for performing multi-way branches, a "case" statement of some form. [It is useful in implementing menu driven programs.] The C switch statement is illustrated in the next example. /* illustrate use of switch statement */ main() char inchar; printf("please enter a character:"); scanf("%c",&inchar); switch(inchar) case 'w': printf("you entered lower case w"); break; case 'm': case 'M': printf("that was an M or m"); break; case 'Z': printf("that was upper case Z"); break; default : printf("i'm not sure what that was"); Notes on Example 4 1. The field designator for character input is %c. 2. In executing the switch statement, the value of the expression in parentheses is compared with the constants in the various cases to determine the action to take. 3. The break statements transfer control to the end of the switch statement. If they were omitted control would fall from one case into the next case. 4. We can have multiple constants associated with a particular action. 5. The default case is performed if none of the others matches. Loops C has three looping statements: while, for and do..while. Two of them are illustrated in the following example where the program prompts for an integer and outputs that number of asterisks. Input of -1 terminates the program. Comp 162 Lab Notes Page 7 of 10 August 26, 2015

8 Example 5 main() int i,count; printf("input count (-1 to terminate): "); scanf("%d",&count); while (count!= -1) for (i = 0; i < count; i++) printf("*"); printf("\n"); printf("input count (-1 to terminate): "); scanf("%d",&count); Notes on Example 5 1. The while statement tests the condition at the beginning of the loop. Braces are necessary when the loop body has more than one statement. 2. There are three clauses in the control part of the for statement: initialization, test and end-of-loop action. is equivalent to for (A; B; C;) action ; A; while (B) action; C; Here is typical output from a run of Example 5 Input count (-1 to terminate): 12 ************ Input count (-1 to terminate): 1 * Input count (-1 to terminate): 0 Input count (-1 to terminate): 6 ****** Input count (-1 to terminate): -1 Comp 162 Lab Notes Page 8 of 10 August 26, 2015

9 Arrays Arrays in C have subscripts starting at 0, the declaration just needs to specify, the type, name and size. The following program reads 4 integers into array A then multiplies each by the corresponding entry in a constant array test. The updated values are then output. Example 8 main() int test[] = 2,3,5,7; int A[4]; int i; printf("enter 4 integers: "); scanf("%d%d%d%d",a,a+1,a+2,a+3); for (i=0; i<4; i++) A[i] *= test[i]; printf("%d %d %d %d\n",a[0],a[1],a[2],a[3]); Example run Enter 4 integers: Notes on Example 8 1. ANSI C permits arrays to be initialized in the manner shown. 2. Array A is of size 4 so its subscripts are scanf needs addresses of locations to store input values. A by itself is an address as are expressions of the form A+n. 4. As in other languages, for loops are a handy way to process arrays. We can have multi-dimensional arrays such as char chessboard [8][8]; float matrix[4][2][5]; Accessing elements requires the appropriate number of subscripts, e.g. matrix[i][j][k]. Comp 162 Lab Notes Page 9 of 10 August 26, 2015

10 Program 1 (due at end of lab on September 2) See handout. Notes 1. script command lets you capture terminal activity to a file. See man script for details. 2. A flash drive is accessible within Unix in the directory /Volumes Comp 162 Lab Notes Page 10 of 10 August 26, 2015

1. The Mac Environment in SIE 1222

1. The Mac Environment in SIE 1222 Friday, September 1, 2017 Lab Notes Topics for today The Mac Environment C (and Unix) Notes on C Part 1 Program 1 1. The Mac Environment in SIE 1222 a. Turning on the Mac If the Mac is in sleep mode you

More information

EL2310 Scientific Programming

EL2310 Scientific Programming (yaseminb@kth.se) Overview Overview Roots of C Getting started with C Closer look at Hello World Programming Environment Discussion Basic Datatypes and printf Schedule Introduction to C - main part of

More information

EL2310 Scientific Programming

EL2310 Scientific Programming Lecture 6: Introduction to C (pronobis@kth.se) Overview Overview Lecture 6: Introduction to C Roots of C Getting started with C Closer look at Hello World Programming Environment Schedule Last time (and

More information

Practical Session 0 Introduction to Linux

Practical Session 0 Introduction to Linux School of Computer Science and Software Engineering Clayton Campus, Monash University CSE2303 and CSE2304 Semester I, 2001 Practical Session 0 Introduction to Linux Novell accounts. Every Monash student

More information

Lab 1 Introduction to UNIX and C

Lab 1 Introduction to UNIX and C Name: Lab 1 Introduction to UNIX and C This first lab is meant to be an introduction to computer environments we will be using this term. You must have a Pitt username to complete this lab. The doc is

More information

CSC111 Computer Science II

CSC111 Computer Science II CSC111 Computer Science II Lab 1 Getting to know Linux Introduction The purpose of this lab is to introduce you to the command line interface in Linux. Getting started In our labs If you are in one of

More information

EL2310 Scientific Programming

EL2310 Scientific Programming Lecture 7: Introduction to C (pronobis@kth.se) Overview Overview Lecture 7: Introduction to C Wrap Up Basic Datatypes and printf Branching and Loops in C Constant values Wrap Up Lecture 7: Introduction

More information

Introduction: The Unix shell and C programming

Introduction: The Unix shell and C programming Introduction: The Unix shell and C programming 1DT048: Programming for Beginners Uppsala University June 11, 2014 You ll be working with the assignments in the Unix labs. If you are new to Unix or working

More information

CMSC 104 Lecture 2 by S Lupoli adapted by C Grasso

CMSC 104 Lecture 2 by S Lupoli adapted by C Grasso CMSC 104 Lecture 2 by S Lupoli adapted by C Grasso A layer of software that runs between the hardware and the user. Controls how the CPU, memory and I/O devices work together to execute programs Keeps

More information

Lab 1 Introduction to UNIX and C

Lab 1 Introduction to UNIX and C Name: Lab 1 Introduction to UNIX and C This first lab is meant to be an introduction to computer environments we will be using this term. You must have a Pitt username to complete this lab. NOTE: Text

More information

Beyond this course. Machine code. Readings: CP:AMA 2.1, 15.4

Beyond this course. Machine code. Readings: CP:AMA 2.1, 15.4 Beyond this course Readings: CP:AMA 2.1, 15.4 CS 136 Spring 2018 13: Beyond 1 Machine code In Section 04 we briefly discussed compiling: converting source code into machine code so it can be run or executed.

More information

Integer Representation. Variables. Real Representation. Integer Overflow/Underflow

Integer Representation. Variables. Real Representation. Integer Overflow/Underflow Variables Integer Representation Variables are used to store a value. The value a variable holds may change over its lifetime. At any point in time a variable stores one value (except quantum computers!)

More information

Programming and Data Structure Laboratory (CS13002)

Programming and Data Structure Laboratory (CS13002) Programming and Data Structure Laboratory (CS13002) Dr. Sudeshna Sarkar Dr. Indranil Sengupta Dept. of Computer Science & Engg., IIT Kharagpur 1 Some Rules to be Followed Attendance is mandatory. Regular

More information

Python for Astronomers. Week 1- Basic Python

Python for Astronomers. Week 1- Basic Python Python for Astronomers Week 1- Basic Python UNIX UNIX is the operating system of Linux (and in fact Mac). It comprises primarily of a certain type of file-system which you can interact with via the terminal

More information

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011 Oregon State University School of Electrical Engineering and Computer Science CS 261 Recitation 1 Spring 2011 Outline Using Secure Shell Clients GCC Some Examples Intro to C * * Windows File transfer client:

More information

PDS Lab Section 16 Autumn Tutorial 1. Unix Commands pwd The pwd command displays the full pathname of the current directory.

PDS Lab Section 16 Autumn Tutorial 1. Unix Commands pwd The pwd command displays the full pathname of the current directory. PDS Lab Section 16 Autumn-2018 Tutorial 1 Unix Commands pwd The pwd command displays the full pathname of the current directory. pwd mkdir The mkdir command creates a single directory or multiple directories.

More information

Intermediate Programming, Spring Misha Kazhdan

Intermediate Programming, Spring Misha Kazhdan 600.120 Intermediate Programming, Spring 2017 Misha Kazhdan Outline Unix/Linux command line Basics of the Emacs editor Compiling and running a simple C program Cloning a repository Connecting to ugrad

More information

Helpful Tips for Labs. CS140, Spring 2015

Helpful Tips for Labs. CS140, Spring 2015 Helpful Tips for Labs CS140, Spring 2015 Linux/Unix Commands Creating, Entering, Changing Directories to Create a Directory (a Folder) on the command line type mkdir folder_name to Enter that Folder cd

More information

3/13/2012. ESc101: Introduction to Computers and Programming Languages

3/13/2012. ESc101: Introduction to Computers and Programming Languages ESc101: Introduction to Computers and Programming Languages Instructor: Krithika Venkataramani Semester 2, 2011-2012 The content of these slides is taken from previous course lectures of Prof. R. K. Ghosh,

More information

Hacking C Code - Local Machine

Hacking C Code - Local Machine Hacking C Code - Local Machine For CS department machines, use your LDAP password, and log in with ssh to remote.cs.binghamton.edu (unless you're actually sitting at a Unix machine in one of the labs,

More information

CSCI 2132 Software Development. Lecture 8: Introduction to C

CSCI 2132 Software Development. Lecture 8: Introduction to C CSCI 2132 Software Development Lecture 8: Introduction to C Instructor: Vlado Keselj Faculty of Computer Science Dalhousie University 21-Sep-2018 (8) CSCI 2132 1 Previous Lecture Filename substitution

More information

Lecture 3. More About C

Lecture 3. More About C Copyright 1996 David R. Hanson Computer Science 126, Fall 1996 3-1 Lecture 3. More About C Programming languages have their lingo Programming language Types are categories of values int, float, char Constants

More information

Introduction to Linux. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University

Introduction to Linux. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University Introduction to Linux Woo-Yeong Jeong (wooyeong@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu What is Linux? A Unix-like operating system of a computer What is an

More information

Introduction to Linux. Fundamentals of Computer Science

Introduction to Linux. Fundamentals of Computer Science Introduction to Linux Fundamentals of Computer Science Outline Operating Systems Linux History Linux Architecture Logging in to Linux Command Format Linux Filesystem Directory and File Commands Wildcard

More information

Saint Louis University. Intro to Linux and C. CSCI 2400/ ECE 3217: Computer Architecture. Instructors: David Ferry

Saint Louis University. Intro to Linux and C. CSCI 2400/ ECE 3217: Computer Architecture. Instructors: David Ferry Intro to Linux and C CSCI 2400/ ECE 3217: Computer Architecture Instructors: David Ferry 1 Overview Linux C Hello program in C Compiling 2 History of Linux Way back in the day: Bell Labs Unix Widely available

More information

Week 1, continued. This is CS50. Harvard University. Fall Cheng Gong

Week 1, continued. This is CS50. Harvard University. Fall Cheng Gong This is CS50. Harvard University. Fall 2014. Cheng Gong Table of Contents Formula SAE at MIT... 1 Introduction... 1 C... 2 Functions and Syntax... 2 Compilers, Commands, and Libraries... 3 Conditions...

More information

Introduction to Algorithms and Programming I Lab. Exercises #1 Solution

Introduction to Algorithms and Programming I Lab. Exercises #1 Solution 60-140 Introduction to Algorithms and Programming I Lab. Exercises #1 Solution Objectives are to: 1. Learn basic Unix commands for preparing a source C program file, compiling a C program and executing

More information

CSE 303 Lecture 8. Intro to C programming

CSE 303 Lecture 8. Intro to C programming CSE 303 Lecture 8 Intro to C programming read C Reference Manual pp. Ch. 1, 2.2-2.4, 2.6, 3.1, 5.1, 7.1-7.2, 7.5.1-7.5.4, 7.6-7.9, Ch. 8; Programming in C Ch. 1-6 slides created by Marty Stepp http://www.cs.washington.edu/303/

More information

UIC. C Programming Primer. Bharathidasan University

UIC. C Programming Primer. Bharathidasan University C Programming Primer UIC C Programming Primer Bharathidasan University Contents Getting Started 02 Basic Concepts. 02 Variables, Data types and Constants...03 Control Statements and Loops 05 Expressions

More information

Basic UNIX Commands BASIC UNIX COMMANDS. 1. cat command. This command is used to create a file in unix. Syntax: $ cat filename

Basic UNIX Commands BASIC UNIX COMMANDS. 1. cat command. This command is used to create a file in unix. Syntax: $ cat filename Basic UNIX Commands BASIC UNIX COMMANDS 1. cat command This command is used to create a file in unix. $ cat >filename This command is also used for displaying contents in a file. $ cat filename 2. ls command

More information

CpSc 1111 Lab 4 Part a Flow Control, Branching, and Formatting

CpSc 1111 Lab 4 Part a Flow Control, Branching, and Formatting CpSc 1111 Lab 4 Part a Flow Control, Branching, and Formatting Your factors.c and multtable.c files are due by Wednesday, 11:59 pm, to be submitted on the SoC handin page at http://handin.cs.clemson.edu.

More information

COMP s1 Lecture 1

COMP s1 Lecture 1 COMP1511 18s1 Lecture 1 1 Numbers In, Numbers Out Andrew Bennett more printf variables scanf 2 Before we begin introduce yourself to the person sitting next to you why did

More information

CS11001/CS11002 Programming and Data Structures Autumn/Spring Semesters. Introduction

CS11001/CS11002 Programming and Data Structures Autumn/Spring Semesters. Introduction Title page CS11001/CS11002 Programming and Data Structures Autumn/Spring Semesters Introduction Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Last modified: July

More information

Laboratory 1 Semester 1 11/12

Laboratory 1 Semester 1 11/12 CS2106 National University of Singapore School of Computing Laboratory 1 Semester 1 11/12 MATRICULATION NUMBER: In this lab exercise, you will get familiarize with some basic UNIX commands, editing and

More information

Course Outline Introduction to C-Programming

Course Outline Introduction to C-Programming ECE3411 Fall 2015 Lecture 1a. Course Outline Introduction to C-Programming Marten van Dijk, Syed Kamran Haider Department of Electrical & Computer Engineering University of Connecticut Email: {vandijk,

More information

CS 2400 Laboratory Assignment #1: Exercises in Compilation and the UNIX Programming Environment (100 pts.)

CS 2400 Laboratory Assignment #1: Exercises in Compilation and the UNIX Programming Environment (100 pts.) 1 Introduction 1 CS 2400 Laboratory Assignment #1: Exercises in Compilation and the UNIX Programming Environment (100 pts.) This laboratory is intended to give you some brief experience using the editing/compiling/file

More information

CpSc 1111 Lab 1 Introduction to Unix Systems, Editors, and C

CpSc 1111 Lab 1 Introduction to Unix Systems, Editors, and C CpSc 1111 Lab 1 Introduction to Unix Systems, Editors, and C Welcome! Welcome to your CpSc 111 lab! For each lab this semester, you will be provided a document like this to guide you. This material, as

More information

Unit 10. Linux Operating System

Unit 10. Linux Operating System 1 Unit 10 Linux Operating System 2 Linux Based on the Unix operating system Developed as an open-source ("free") alternative by Linux Torvalds and several others starting in 1991 Originally only for Intel

More information

CS11002 Programming and Data Structures Spring Introduction

CS11002 Programming and Data Structures Spring Introduction Title page CS11002 Programming and Data Structures Spring 2008 Goutam Biswas Abhijit Das Dipankar Sarkar Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Jan 04, 2008

More information

Introduction to Linux

Introduction to Linux Introduction to Linux Prof. Jin-Soo Kim( jinsookim@skku.edu) TA - Dong-Yun Lee (dylee@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu What is Linux? A Unix-like operating

More information

AN OVERVIEW OF C. CSE 130: Introduction to Programming in C Stony Brook University

AN OVERVIEW OF C. CSE 130: Introduction to Programming in C Stony Brook University AN OVERVIEW OF C CSE 130: Introduction to Programming in C Stony Brook University WHY C? C is a programming lingua franca Millions of lines of C code exist Many other languages use C-like syntax C is portable

More information

Tutorial 1: Unix Basics

Tutorial 1: Unix Basics Tutorial 1: Unix Basics To log in to your ece account, enter your ece username and password in the space provided in the login screen. Note that when you type your password, nothing will show up in the

More information

Basic Unix Commands. CGS 3460, Lecture 6 Jan 23, 2006 Zhen Yang

Basic Unix Commands. CGS 3460, Lecture 6 Jan 23, 2006 Zhen Yang Basic Unix Commands CGS 3460, Lecture 6 Jan 23, 2006 Zhen Yang For this class you need to work from your grove account to finish your homework Knowing basic UNIX commands is essential to finish your homework

More information

The C language. Introductory course #1

The C language. Introductory course #1 The C language Introductory course #1 History of C Born at AT&T Bell Laboratory of USA in 1972. Written by Dennis Ritchie C language was created for designing the UNIX operating system Quickly adopted

More information

Introduction: What is Unix?

Introduction: What is Unix? Introduction Introduction: What is Unix? An operating system Developed at AT&T Bell Labs in the 1960 s Command Line Interpreter GUIs (Window systems) are now available Introduction: Unix vs. Linux Unix

More information

Introduction to Linux

Introduction to Linux Introduction to Linux Prof. Jin-Soo Kim( jinsookim@skku.edu) TA Sanghoon Han(sanghoon.han@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Announcement (1) Please come

More information

CS19001/CS19002 Programming and Data Structures Lab Autumn/Spring Semester. Introduction. Abhijit Das. January 4, 2015

CS19001/CS19002 Programming and Data Structures Lab Autumn/Spring Semester. Introduction. Abhijit Das. January 4, 2015 Title page CS19001/CS19002 Programming and Data Structures Lab Autumn/Spring Semester Introduction Abhijit Das Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur January

More information

User Guide Version 2.0

User Guide Version 2.0 User Guide Version 2.0 Page 2 of 8 Summary Contents 1 INTRODUCTION... 3 2 SECURESHELL (SSH)... 4 2.1 ENABLING SSH... 4 2.2 DISABLING SSH... 4 2.2.1 Change Password... 4 2.2.2 Secure Shell Connection Information...

More information

Linux & Shell Programming 2014

Linux & Shell Programming 2014 Unit -1: Introduction to UNIX/LINUX Operating System Practical Practice Questions: Find errors (if any) otherwise write output or interpretation of following commands. (Consider default shell is bash shell.)

More information

CS102: Standard I/O. %<flag(s)><width><precision><size>conversion-code

CS102: Standard I/O. %<flag(s)><width><precision><size>conversion-code CS102: Standard I/O Our next topic is standard input and standard output in C. The adjective "standard" when applied to "input" or "output" could be interpreted to mean "default". Typically, standard output

More information

27-Sep CSCI 2132 Software Development Lecture 10: Formatted Input and Output. Faculty of Computer Science, Dalhousie University. Lecture 10 p.

27-Sep CSCI 2132 Software Development Lecture 10: Formatted Input and Output. Faculty of Computer Science, Dalhousie University. Lecture 10 p. Lecture 10 p.1 Faculty of Computer Science, Dalhousie University CSCI 2132 Software Development Lecture 10: Formatted Input and Output 27-Sep-2017 Location: Goldberg CS 127 Time: 14:35 15:25 Instructor:

More information

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University Unix/Linux Basics 1 Some basics to remember Everything is case sensitive Eg., you can have two different files of the same name but different case in the same folder Console-driven (same as terminal )

More information

Physics 306 Computing Lab 1: Hello, World!

Physics 306 Computing Lab 1: Hello, World! 1. Introduction Physics 306 Computing Lab 1: Hello, World! In today s lab, you will learn how to write simple programs, to compile them, and to run them. You will learn about input and output, variables,

More information

The Unix Shell & Shell Scripts

The Unix Shell & Shell Scripts The Unix Shell & Shell Scripts You should do steps 1 to 7 before going to the lab. Use the Linux system you installed in the previous lab. In the lab do step 8, the TA may give you additional exercises

More information

27-Sep CSCI 2132 Software Development Lab 4: Exploring bash and C Compilation. Faculty of Computer Science, Dalhousie University

27-Sep CSCI 2132 Software Development Lab 4: Exploring bash and C Compilation. Faculty of Computer Science, Dalhousie University Lecture 4 p.1 Faculty of Computer Science, Dalhousie University CSCI 2132 Software Development Lab 4: Exploring bash and C Compilation 27-Sep-2017 Location: Goldberg CS Building Time: Wednesday, 16:05

More information

Getting started with UNIX/Linux for G51PRG and G51CSA

Getting started with UNIX/Linux for G51PRG and G51CSA Getting started with UNIX/Linux for G51PRG and G51CSA David F. Brailsford Steven R. Bagley 1. Introduction These first exercises are very simple and are primarily to get you used to the systems we shall

More information

Introduction to C An overview of the programming language C, syntax, data types and input/output

Introduction to C An overview of the programming language C, syntax, data types and input/output Introduction to C An overview of the programming language C, syntax, data types and input/output Teil I. a first C program TU Bergakademie Freiberg INMO M. Brändel 2018-10-23 1 PROGRAMMING LANGUAGE C is

More information

Introduction to Supercomputing

Introduction to Supercomputing Introduction to Supercomputing TMA4280 Introduction to UNIX environment and tools 0.1 Getting started with the environment and the bash shell interpreter Desktop computers are usually operated from a graphical

More information

Unix and C Program Development SEEM

Unix and C Program Development SEEM Unix and C Program Development SEEM 3460 1 Operating Systems A computer system cannot function without an operating system (OS). There are many different operating systems available for PCs, minicomputers,

More information

Lecture 6. Statements

Lecture 6. Statements Lecture 6 Statements 1 Statements This chapter introduces the various forms of C++ statements for composing programs You will learn about Expressions Composed instructions Decision instructions Loop instructions

More information

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #03 The Programming Cycle

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #03 The Programming Cycle Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #03 The Programming Cycle (Refer Slide Time: 00:22) Once we are understood what algorithms are, we will start

More information

CS50 Supersection (for those less comfortable)

CS50 Supersection (for those less comfortable) CS50 Supersection (for those less comfortable) Friday, September 8, 2017 3 4pm, Science Center C Maria Zlatkova, Doug Lloyd Today s Topics Setting up CS50 IDE Variables and Data Types Conditions Boolean

More information

C: How to Program. Week /Mar/05

C: How to Program. Week /Mar/05 1 C: How to Program Week 2 2007/Mar/05 Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers

More information

Parallel Programming Pre-Assignment. Setting up the Software Environment

Parallel Programming Pre-Assignment. Setting up the Software Environment Parallel Programming Pre-Assignment Setting up the Software Environment Authors: B. Wilkinson and C. Ferner. Modification date: Aug 21, 2014 (Minor correction Aug 27, 2014.) Software The purpose of this

More information

Getting Started With UNIX Lab Exercises

Getting Started With UNIX Lab Exercises Getting Started With UNIX Lab Exercises This is the lab exercise handout for the Getting Started with UNIX tutorial. The exercises provide hands-on experience with the topics discussed in the tutorial.

More information

بسم اهلل الرمحن الرحيم

بسم اهلل الرمحن الرحيم بسم اهلل الرمحن الرحيم Fundamentals of Programming C Session # 10 By: Saeed Haratian Fall 2015 Outlines Examples Using the for Statement switch Multiple-Selection Statement do while Repetition Statement

More information

MEIN 50010: Python Introduction

MEIN 50010: Python Introduction : Python Fabian Sievers Higgins Lab, Conway Institute University College Dublin Wednesday, 2017-10-04 Outline Goals Teach basic programming concepts Apply these concepts using Python Use Python Packages

More information

Running a C program Compilation Python and C Variables and types Data and addresses Functions Performance. John Edgar 2

Running a C program Compilation Python and C Variables and types Data and addresses Functions Performance. John Edgar 2 CMPT 125 Running a C program Compilation Python and C Variables and types Data and addresses Functions Performance John Edgar 2 Edit or write your program Using a text editor like gedit Save program with

More information

CSCE 212H, Spring 2008, Matthews Lab Assignment 1: Representation of Integers Assigned: January 17 Due: January 22

CSCE 212H, Spring 2008, Matthews Lab Assignment 1: Representation of Integers Assigned: January 17 Due: January 22 CSCE 212H, Spring 2008, Matthews Lab Assignment 1: Representation of Integers Assigned: January 17 Due: January 22 Manton Matthews January 29, 2008 1 Overview The purpose of this assignment is to become

More information

Lecture 1. A. Sahu and S. V. Rao. Indian Institute of Technology Guwahati

Lecture 1. A. Sahu and S. V. Rao. Indian Institute of Technology Guwahati Lecture 1 Introduction to Computing A. Sahu and S. V. Rao Dept of Comp. Sc. & Engg. Indian Institute of Technology Guwahati 1 Outline Computer System Problem Solving and Flow Chart Linux Command ls, mkdir,

More information

Exercise 1: Basic Tools

Exercise 1: Basic Tools Exercise 1: Basic Tools This exercise is created so everybody can learn the basic tools we will use during this course. It is really more like a tutorial than an exercise and, you are not required to submit

More information

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 05 I/O statements Printf, Scanf Simple

More information

Summary of Last Class. Processes. C vs. Java. C vs. Java (cont.) C vs. Java (cont.) Tevfik Ko!ar. CSC Systems Programming Fall 2008

Summary of Last Class. Processes. C vs. Java. C vs. Java (cont.) C vs. Java (cont.) Tevfik Ko!ar. CSC Systems Programming Fall 2008 CSC 4304 - Systems Programming Fall 2008 Lecture - II Basics of C Programming Summary of Last Class Basics of UNIX: logging in, changing password text editing with vi, emacs and pico file and director

More information

CENG393 Computer Networks Labwork 1

CENG393 Computer Networks Labwork 1 CENG393 Computer Networks Labwork 1 Linux is the common name given to a large family of operating systems. All Linux-based operating systems are essentially a large set of computer software that are bound

More information

: the User (owner) for this file (your cruzid, when you do it) Position: directory flag. read Group.

: the User (owner) for this file (your cruzid, when you do it) Position: directory flag. read Group. CMPS 12L Introduction to Programming Lab Assignment 2 We have three goals in this assignment: to learn about file permissions in Unix, to get a basic introduction to the Andrew File System and it s directory

More information

Physics REU Unix Tutorial

Physics REU Unix Tutorial Physics REU Unix Tutorial What is unix? Unix is an operating system. In simple terms, its the set of programs that makes a computer work. It can be broken down into three parts. (1) kernel: The component

More information

introduction week 1 Ritsumeikan University College of Information Science and Engineering Ian Piumarta 1 / 20 imperative programming about the course

introduction week 1 Ritsumeikan University College of Information Science and Engineering Ian Piumarta 1 / 20 imperative programming about the course week 1 introduction Ritsumeikan University College of Information Science and Engineering Ian Piumarta 1 / 20 class format 30 minutes (give or take a few) presentation 60 minutes (give or take a few) practice

More information

Refresher workshop in programming for polytechnic graduates General Java Program Compilation Guide

Refresher workshop in programming for polytechnic graduates General Java Program Compilation Guide Refresher workshop in programming for polytechnic graduates General Java Program Compilation Guide Overview Welcome to this refresher workshop! This document will serve as a self-guided explanation to

More information

C Overview Fall 2014 Jinkyu Jeong

C Overview Fall 2014 Jinkyu Jeong C Overview Fall 2014 Jinkyu Jeong (jinkyu@skku.edu) 1 # for preprocessor Indicates where to look for printf() function.h file is a header file #include int main(void) { printf("hello, world!\n");

More information

Computers and Computation. The Modern Computer. The Operating System. The Operating System

Computers and Computation. The Modern Computer. The Operating System. The Operating System The Modern Computer Computers and Computation What is a computer? A machine that manipulates data according to instructions. Despite their apparent complexity, at the lowest level computers perform simple

More information

.. Cal Poly CPE 101: Fundamentals of Computer Science I Alexander Dekhtyar..

.. Cal Poly CPE 101: Fundamentals of Computer Science I Alexander Dekhtyar.. .. Cal Poly CPE 101: Fundamentals of Computer Science I Alexander Dekhtyar.. A Simple Program. simple.c: Basics of C /* CPE 101 Fall 2008 */ /* Alex Dekhtyar */ /* A simple program */ /* This is a comment!

More information

CMPT 115. C tutorial for students who took 111 in Java. University of Saskatchewan. Mark G. Eramian, Ian McQuillan CMPT 115 1/32

CMPT 115. C tutorial for students who took 111 in Java. University of Saskatchewan. Mark G. Eramian, Ian McQuillan CMPT 115 1/32 CMPT 115 C tutorial for students who took 111 in Java Mark G. Eramian Ian McQuillan University of Saskatchewan Mark G. Eramian, Ian McQuillan CMPT 115 1/32 Part I Starting out Mark G. Eramian, Ian McQuillan

More information

AMS 200: Working on Linux/Unix Machines

AMS 200: Working on Linux/Unix Machines AMS 200, Oct 20, 2014 AMS 200: Working on Linux/Unix Machines Profs. Nic Brummell (brummell@soe.ucsc.edu) & Dongwook Lee (dlee79@ucsc.edu) Department of Applied Mathematics and Statistics University of

More information

gcc hello.c a.out Hello, world gcc -o hello hello.c hello Hello, world

gcc hello.c a.out Hello, world gcc -o hello hello.c hello Hello, world alun@debian:~$ gcc hello.c alun@debian:~$ a.out Hello, world alun@debian:~$ gcc -o hello hello.c alun@debian:~$ hello Hello, world alun@debian:~$ 1 A Quick guide to C for Networks and Operating Systems

More information

CMPUT 201: Practical Programming Methodology. Guohui Lin Department of Computing Science University of Alberta September 2018

CMPUT 201: Practical Programming Methodology. Guohui Lin Department of Computing Science University of Alberta September 2018 CMPUT 201: Practical Programming Methodology Guohui Lin guohui@ualberta.ca Department of Computing Science University of Alberta September 2018 Lecture 1: Course Outline Agenda: Course calendar description

More information

CPE 101, reusing/mod slides from a UW course (used by permission) Lecture 5: Input and Output (I/O)

CPE 101, reusing/mod slides from a UW course (used by permission) Lecture 5: Input and Output (I/O) CPE 101, reusing/mod slides from a UW course (used by permission) Lecture 5: Input and Output (I/O) Overview (5) Topics Output: printf Input: scanf Basic format codes More on initializing variables 2000

More information

C Language Part 2 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee

C Language Part 2 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee C Language Part 2 (Minor modifications by the instructor) 1 Scope Rules A variable declared inside a function is a local variable Each local variable in a function comes into existence when the function

More information

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Mauro Ceccanti e Alberto Paoluzzi

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Mauro Ceccanti e Alberto Paoluzzi Lezione 8 Bioinformatica Mauro Ceccanti e Alberto Paoluzzi Dip. Informatica e Automazione Università Roma Tre Dip. Medicina Clinica Università La Sapienza Sommario Shell command language Introduction A

More information

Introduction to Linux

Introduction to Linux Introduction to Linux The command-line interface A command-line interface (CLI) is a type of interface, that is, a way to interact with a computer. Window systems, punched cards or a bunch of dials, buttons

More information

LAB 1 INTRODUCTION TO LINUX ENVIRONMENT AND C COMPILER

LAB 1 INTRODUCTION TO LINUX ENVIRONMENT AND C COMPILER LAB 1 INTRODUCTION TO LINUX ENVIRONMENT AND C COMPILER School of Computer and Communication Engineering Universiti Malaysia Perlis 1 1. GETTING STARTED: 1.1 Steps to Create New Folder: 1.1.1 Click Places

More information

Operating Systems and Using Linux. Topics What is an Operating System? Linux Overview Frequently Used Linux Commands

Operating Systems and Using Linux. Topics What is an Operating System? Linux Overview Frequently Used Linux Commands Operating Systems and Using Linux Topics What is an Operating System? Linux Overview Frequently Used Linux Commands 1 What is an Operating System? A computer program that: Controls how the CPU, memory

More information

Introduction to the UNIX command line

Introduction to the UNIX command line Introduction to the UNIX command line Steven Abreu Introduction to Computer Science (ICS) Tutorial Jacobs University s.abreu@jacobs-university.de September 19, 2017 Overview What is UNIX? UNIX Shell Commands

More information

Continued from previous lecture

Continued from previous lecture The Design of C: A Rational Reconstruction: Part 2 Jennifer Rexford Continued from previous lecture 2 Agenda Data Types Statements What kinds of operators should C have? Should handle typical operations

More information

Chapter-3. Introduction to Unix: Fundamental Commands

Chapter-3. Introduction to Unix: Fundamental Commands Chapter-3 Introduction to Unix: Fundamental Commands What You Will Learn The fundamental commands of the Unix operating system. Everything told for Unix here is applicable to the Linux operating system

More information

EE/CSCI 451 Introduction to Parallel and Distributed Computation. Discussion #4 2/3/2017 University of Southern California

EE/CSCI 451 Introduction to Parallel and Distributed Computation. Discussion #4 2/3/2017 University of Southern California EE/CSCI 451 Introduction to Parallel and Distributed Computation Discussion #4 2/3/2017 University of Southern California 1 USC HPCC Access Compile Submit job OpenMP Today s topic What is OpenMP OpenMP

More information

Introduction to the Linux Command Line

Introduction to the Linux Command Line Introduction to the Linux Command Line May, 2015 How to Connect (securely) ssh sftp scp Basic Unix or Linux Commands Files & directories Environment variables Not necessarily in this order.? Getting Connected

More information

Introduction to Cygwin Operating Environment

Introduction to Cygwin Operating Environment Introduction to Cygwin Operating Environment ICT 106 Fundamentals of Computer Systems Eric Li ICT106_Pract_week 1 1 What s Cygwin? Emulates Unix/Linux environment on a Windows Operating System; A collection

More information

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Esercitazione Introduzione al linguaggio di shell

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Esercitazione Introduzione al linguaggio di shell Lezione 8 Bioinformatica Mauro Ceccanti e Alberto Paoluzzi Esercitazione Introduzione al linguaggio di shell Dip. Informatica e Automazione Università Roma Tre Dip. Medicina Clinica Università La Sapienza

More information

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines Introduction to UNIX Logging in Basic system architecture Getting help Intro to shell (tcsh) Basic UNIX File Maintenance Intro to emacs I/O Redirection Shell scripts Logging in most systems have graphical

More information

REU C Programming Tutorial: Part I FIRST PROGRAM

REU C Programming Tutorial: Part I FIRST PROGRAM REU C Programming Tutorial: Part I What is C? C is a programming language. This means that it can be used to send the computer a set of instructions in a human-understandable way, which the computer interprets

More information