SlideShare a Scribd company logo
CS 262
George Mason University
Department of Computer Science
Syllabus
www.hamzamughal.com
Also available on the course blackboard page
A brief introduction to C
Where?
in the Computer Science Research Department of Bell Labs in Murray Hill, NJ
Who?
by Dennis Ritchie
Why?
Previous languages (such as B) were difficult to implement programs in due to
various issues such as hardware constraints and B being incredibly slow due to it being
an interpreted language (executed by software running on top of the CPU)
C was developed to move code from assembly to a “higher” language, being
tied to the development of Unix to provide more control
https://www.bell-labs.com/usr/dmr/www/chist.pdf
ANSI (American National Standards Institute) standardized C in 1989 to create ANSI C
The International standard (ISO) was adopted by ANSI in 1990 which is known as C89
Updates in 1995 (C05) and 1999 (C99), latest being in 2018 (C18)
More on ANSI C
C is a “medium level” programming language that lets us use it at a “low level”
Contains the usual structures that many “high level” languages offer to us but also
allowing us to incorporate assembly to directly access the memory
Numerous library functions available that may be imported
Structure of a C Program
Consists of one or more functions (not methods as they are called in Java)
Program consists of executing the main function
int main (void) { … }
int main (int argc, char (argv[]) { … }
Functions contain:
A heading (data type return, name, optional arguments)
Argument declarations (if any optional arguments)
Statements (code inside the curly braces)
Preprocessors (macros, compiler controls, constant values, libraries, etc)
Additional local and external functions and variables
Recall control returns to the place where a function was called (may or may not return
with a value)
Expressions must end with a semlcolon (same as Java)
Compound instructions must be enclosed with curly braces { … }
Comments delimited by // or by multi line comments /* */
Brief intro to language processing systems
Pre processing
Compiling
Assembly
Linkage
Source Code
.i file
.s file
.o file
.exe file
Compiler Architecture
GCC
GNU Compiler Collection (aka gcc)
optimizing compiler which we will use to compile our c code
How do we utilize gcc exactly?
gcc –o hello hello.c
This command basically says compile “hello.c” to machine code name hello
“hello” is now created, now how do we run it?
./hello
Executes hello
./ is necessary (.’ specifies the directory you’re in currently)
Pitfalls
Easy to write spaghetti code since C is procedural
Preprocessors can get messy quick
Unable to gracefully terminate (meaning no catch/throw/exceptions!)
Not much of OOP
Many more which I’ve not included here…
Connecting to Zeus
Off campus?
Download the Cisco VPN https://its.gmu.edu/service/virtual-private-network-
vpn/
Connecting by SSH to Zeus via command line
ssh username@zeus.vse.gmu.edu
Download the SSH client
https://labs.vse.gmu.edu/index.php/FAQ/SSH
Copying files from/to Zeus
From your computer to Zeus
scp local user_zeus.vse.gmu.edu:~/.
From Zeus to your computer
scp user@zeus.vse.gmu.edu:~/remote local
Windows users need to use Putty
https://its.gmu.edu/knowledge-base/how-to-install-putty-ssh-for-
windows/
Shell
A command line interpreter which runs commands, programs, shell scripts
bash being the standard shell and the $ character being its default prompt
Some commands which you may utilize the most:
clear pwd ls cd cp mv rm mkdir rmdir cat
man
Vi/Vim
We will utilize vi/vim on Zeus
Text editor to create/edit files
Two modes:
Command mode and Insert Mode
Command mode to insert mode – type i
Insert mode to command mode – hit the escape key
Some commands which you may find useful:
vim filename (create a file named filename or edit existing file if it exists)
:wq (write file and exit)
:q (Quits, warning is printed if current file is not saved prior)
:q! (Quits with no warning)
:w (Save file)
Java and C Comparisons
Java runs on the JVM, provides a safe programming environment by allowing stuff
such as array bounds checks
C runs on the machine directly which does not contain such sanity checks that Java
has
Java C
Portable 1 0
Efficient 0 1
Safe 1 0
Java C
Strings String s = “Hello”; char * s = “Hello”;
char s2[6];
strcpy(s2, “Hello”)
String Concatenation s1 + s2 #include <string.h>
strcat(s1,s2)
Arrays Int [] x = new int[10]; Int x[10];
Array bounds checks Occurs at run time No run time checks
Pointers Objects are implicit pointers Int *p
Fundamentals
Variables
Consist of letters and/or digits. They should not be key words, they can’t contain
special symbols, such as blanks, -, ", etc.
A few C Keywords
typedef, return, for, char, if, goto, …
The first character must be a letter or the symbol (_)
An uppercase letter is not equivalent to a lowercase
Constants
Like variables, except their values never change
Also known as literals, need to specify the data type of the constant
Common practice to define constants in UPPER-CASE
const data_type constant_name;
Macro defined constants:
#define id value
Data Types
char – Character (1 byte)
Int – Integer (4 bytes)
float – Floating point numbers (4 bytes)
double – Floating point with double precision (8 bytes)
These data type may be coupled with the words – unsigned, signed, short, and long
before the data type
The bit size assigned to the data type usually depends on the capacity of the computer
and the compiler used. However, a char is always 1 byte.
Declarations
Conversion Types
To indicate a data type, the sign % is placed before the conversion character
printf(format string, val1, val2);
Placeholders can also specify widths and precisions
%10d : add spaces to take up at least 10 characters
%010d : add zeros to take up at least 10 characters
%.2f : print only 2 digits after decimal point
%5.2f : print 1 decimal digit, add spaces to take up 5 chars
What happens here?
Escape sequences
b Backspace
t Horizontal tab
n New line
" Quotation marks
' Apostrophe
0 Null Character
 Backward slash
Exercises
Compute the circumference and area of a circle with a given radius.
Print the ASCII value of a character
Tasks this week
Familiarize yourself with a text editor
Learn to work with Unix commands
Lab 1
Working with Zeus
“All theory and no practice makes Jack a dull boy”

More Related Content

Similar to cs262_intro_slides.pptx

Introduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfIntroduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdf
AnassElHousni
 
Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c language
farishah
 
C++ programming language basic to advance level
C++ programming language basic to advance levelC++ programming language basic to advance level
C++ programming language basic to advance level
sajjad ali khan
 
C LANGUAGE UNIT-1 PREPARED BY MVB REDDY
C LANGUAGE UNIT-1 PREPARED BY MVB REDDYC LANGUAGE UNIT-1 PREPARED BY MVB REDDY
C LANGUAGE UNIT-1 PREPARED BY MVB REDDYRajeshkumar Reddy
 
Basics of c Nisarg Patel
Basics of c Nisarg PatelBasics of c Nisarg Patel
Basics of c Nisarg Patel
TechNGyan
 
C Programming UNIT 1.pptx
C Programming  UNIT 1.pptxC Programming  UNIT 1.pptx
C Programming UNIT 1.pptx
Mugilvannan11
 
Lab 1.pptx
Lab 1.pptxLab 1.pptx
Lab 1.pptx
MohammedAlobaidy16
 
Basic c
Basic cBasic c
Basic c
Veera Karthi
 
Unit 1 c - all topics
Unit 1   c - all topicsUnit 1   c - all topics
Unit 1 c - all topics
veningstonk
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programmingAlpana Gupta
 
67404923-C-Programming-Tutorials-Doc.pdf
67404923-C-Programming-Tutorials-Doc.pdf67404923-C-Programming-Tutorials-Doc.pdf
67404923-C-Programming-Tutorials-Doc.pdf
Rajb54
 
The C++ Programming Language
The C++ Programming LanguageThe C++ Programming Language
The C++ Programming Language
Prof Ansari
 
cmp104 lec 8
cmp104 lec 8cmp104 lec 8
cmp104 lec 8kapil078
 
C intro
C introC intro
C intro
Mohit Patodia
 
Lecture 01 2017
Lecture 01 2017Lecture 01 2017
Lecture 01 2017
Jesmin Akhter
 
C++Basics2022.pptx
C++Basics2022.pptxC++Basics2022.pptx
C++Basics2022.pptx
Danielle780357
 
Debug tutorial
Debug tutorialDebug tutorial
Debug tutorialDefri N
 
Introduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxIntroduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptx
NEHARAJPUT239591
 
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJIntroduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
meharikiros2
 

Similar to cs262_intro_slides.pptx (20)

Introduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfIntroduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdf
 
Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c language
 
C++ programming language basic to advance level
C++ programming language basic to advance levelC++ programming language basic to advance level
C++ programming language basic to advance level
 
C LANGUAGE UNIT-1 PREPARED BY MVB REDDY
C LANGUAGE UNIT-1 PREPARED BY MVB REDDYC LANGUAGE UNIT-1 PREPARED BY MVB REDDY
C LANGUAGE UNIT-1 PREPARED BY MVB REDDY
 
Basics of c Nisarg Patel
Basics of c Nisarg PatelBasics of c Nisarg Patel
Basics of c Nisarg Patel
 
C PROGRAMMING
C PROGRAMMINGC PROGRAMMING
C PROGRAMMING
 
C Programming UNIT 1.pptx
C Programming  UNIT 1.pptxC Programming  UNIT 1.pptx
C Programming UNIT 1.pptx
 
Lab 1.pptx
Lab 1.pptxLab 1.pptx
Lab 1.pptx
 
Basic c
Basic cBasic c
Basic c
 
Unit 1 c - all topics
Unit 1   c - all topicsUnit 1   c - all topics
Unit 1 c - all topics
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
67404923-C-Programming-Tutorials-Doc.pdf
67404923-C-Programming-Tutorials-Doc.pdf67404923-C-Programming-Tutorials-Doc.pdf
67404923-C-Programming-Tutorials-Doc.pdf
 
The C++ Programming Language
The C++ Programming LanguageThe C++ Programming Language
The C++ Programming Language
 
cmp104 lec 8
cmp104 lec 8cmp104 lec 8
cmp104 lec 8
 
C intro
C introC intro
C intro
 
Lecture 01 2017
Lecture 01 2017Lecture 01 2017
Lecture 01 2017
 
C++Basics2022.pptx
C++Basics2022.pptxC++Basics2022.pptx
C++Basics2022.pptx
 
Debug tutorial
Debug tutorialDebug tutorial
Debug tutorial
 
Introduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxIntroduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptx
 
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJIntroduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
 

Recently uploaded

[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
awadeshbabu
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
Building Electrical System Design & Installation
Building Electrical System Design & InstallationBuilding Electrical System Design & Installation
Building Electrical System Design & Installation
symbo111
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
drwaing
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
Mukeshwaran Balu
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
camseq
 
Self-Control of Emotions by Slidesgo.pptx
Self-Control of Emotions by Slidesgo.pptxSelf-Control of Emotions by Slidesgo.pptx
Self-Control of Emotions by Slidesgo.pptx
iemerc2024
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
gestioneergodomus
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.pptPROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
bhadouriyakaku
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
Kamal Acharya
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
heavyhaig
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
anoopmanoharan2
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 

Recently uploaded (20)

[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
Building Electrical System Design & Installation
Building Electrical System Design & InstallationBuilding Electrical System Design & Installation
Building Electrical System Design & Installation
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
 
Self-Control of Emotions by Slidesgo.pptx
Self-Control of Emotions by Slidesgo.pptxSelf-Control of Emotions by Slidesgo.pptx
Self-Control of Emotions by Slidesgo.pptx
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.pptPROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 

cs262_intro_slides.pptx

  • 1. CS 262 George Mason University Department of Computer Science
  • 4. Where? in the Computer Science Research Department of Bell Labs in Murray Hill, NJ Who? by Dennis Ritchie Why? Previous languages (such as B) were difficult to implement programs in due to various issues such as hardware constraints and B being incredibly slow due to it being an interpreted language (executed by software running on top of the CPU) C was developed to move code from assembly to a “higher” language, being tied to the development of Unix to provide more control https://www.bell-labs.com/usr/dmr/www/chist.pdf
  • 5.
  • 6. ANSI (American National Standards Institute) standardized C in 1989 to create ANSI C The International standard (ISO) was adopted by ANSI in 1990 which is known as C89 Updates in 1995 (C05) and 1999 (C99), latest being in 2018 (C18)
  • 7. More on ANSI C C is a “medium level” programming language that lets us use it at a “low level” Contains the usual structures that many “high level” languages offer to us but also allowing us to incorporate assembly to directly access the memory Numerous library functions available that may be imported
  • 8. Structure of a C Program
  • 9. Consists of one or more functions (not methods as they are called in Java) Program consists of executing the main function int main (void) { … } int main (int argc, char (argv[]) { … } Functions contain: A heading (data type return, name, optional arguments) Argument declarations (if any optional arguments) Statements (code inside the curly braces)
  • 10. Preprocessors (macros, compiler controls, constant values, libraries, etc) Additional local and external functions and variables Recall control returns to the place where a function was called (may or may not return with a value) Expressions must end with a semlcolon (same as Java) Compound instructions must be enclosed with curly braces { … } Comments delimited by // or by multi line comments /* */
  • 11.
  • 12.
  • 13.
  • 14. Brief intro to language processing systems
  • 17. GCC GNU Compiler Collection (aka gcc) optimizing compiler which we will use to compile our c code How do we utilize gcc exactly? gcc –o hello hello.c This command basically says compile “hello.c” to machine code name hello “hello” is now created, now how do we run it? ./hello Executes hello ./ is necessary (.’ specifies the directory you’re in currently)
  • 18. Pitfalls Easy to write spaghetti code since C is procedural Preprocessors can get messy quick Unable to gracefully terminate (meaning no catch/throw/exceptions!) Not much of OOP Many more which I’ve not included here…
  • 20. Off campus? Download the Cisco VPN https://its.gmu.edu/service/virtual-private-network- vpn/ Connecting by SSH to Zeus via command line ssh username@zeus.vse.gmu.edu Download the SSH client https://labs.vse.gmu.edu/index.php/FAQ/SSH
  • 21. Copying files from/to Zeus From your computer to Zeus scp local user_zeus.vse.gmu.edu:~/. From Zeus to your computer scp user@zeus.vse.gmu.edu:~/remote local Windows users need to use Putty https://its.gmu.edu/knowledge-base/how-to-install-putty-ssh-for- windows/
  • 22. Shell A command line interpreter which runs commands, programs, shell scripts bash being the standard shell and the $ character being its default prompt Some commands which you may utilize the most: clear pwd ls cd cp mv rm mkdir rmdir cat man
  • 24. We will utilize vi/vim on Zeus Text editor to create/edit files Two modes: Command mode and Insert Mode Command mode to insert mode – type i Insert mode to command mode – hit the escape key
  • 25. Some commands which you may find useful: vim filename (create a file named filename or edit existing file if it exists) :wq (write file and exit) :q (Quits, warning is printed if current file is not saved prior) :q! (Quits with no warning) :w (Save file)
  • 26. Java and C Comparisons
  • 27. Java runs on the JVM, provides a safe programming environment by allowing stuff such as array bounds checks C runs on the machine directly which does not contain such sanity checks that Java has
  • 28. Java C Portable 1 0 Efficient 0 1 Safe 1 0
  • 29. Java C Strings String s = “Hello”; char * s = “Hello”; char s2[6]; strcpy(s2, “Hello”) String Concatenation s1 + s2 #include <string.h> strcat(s1,s2) Arrays Int [] x = new int[10]; Int x[10]; Array bounds checks Occurs at run time No run time checks Pointers Objects are implicit pointers Int *p
  • 31. Variables Consist of letters and/or digits. They should not be key words, they can’t contain special symbols, such as blanks, -, ", etc. A few C Keywords typedef, return, for, char, if, goto, … The first character must be a letter or the symbol (_) An uppercase letter is not equivalent to a lowercase
  • 32. Constants Like variables, except their values never change Also known as literals, need to specify the data type of the constant Common practice to define constants in UPPER-CASE const data_type constant_name; Macro defined constants: #define id value
  • 33. Data Types char – Character (1 byte) Int – Integer (4 bytes) float – Floating point numbers (4 bytes) double – Floating point with double precision (8 bytes) These data type may be coupled with the words – unsigned, signed, short, and long before the data type The bit size assigned to the data type usually depends on the capacity of the computer and the compiler used. However, a char is always 1 byte.
  • 35. Conversion Types To indicate a data type, the sign % is placed before the conversion character
  • 36. printf(format string, val1, val2); Placeholders can also specify widths and precisions %10d : add spaces to take up at least 10 characters %010d : add zeros to take up at least 10 characters %.2f : print only 2 digits after decimal point %5.2f : print 1 decimal digit, add spaces to take up 5 chars
  • 37.
  • 39.
  • 40. Escape sequences b Backspace t Horizontal tab n New line " Quotation marks ' Apostrophe 0 Null Character Backward slash
  • 41.
  • 42.
  • 44. Compute the circumference and area of a circle with a given radius.
  • 45. Print the ASCII value of a character
  • 46. Tasks this week Familiarize yourself with a text editor Learn to work with Unix commands Lab 1 Working with Zeus “All theory and no practice makes Jack a dull boy”