SlideShare a Scribd company logo
1 of 19
CSE240 – Introduction to
Programming Languages
Lecture 06:
Programming with C
Javier Gonzalez-Sanchez
javiergs@asu.edu
javiergs.engineering.asu.edu
Office Hours: By appointment
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 2
Imperative Paradigm
Fully specified and fully controlled
manipulation of named data in a stepwise fashion.
which means that:
Programs are algorithmic in nature:
do this, then that, then repeat this ten times
Focuses on how rather than what.
variables
functions (methods in Java)
Loop statements
Conditional statements
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 3
Paradigms
variables
functions (methods in Java)
Loop statements
Conditional statements
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 4
Paradigms
variables
functions (methods in Java)
Loop statements
Conditional statements
// Different from
// Java
Arrays
Structs
Pointers
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 5
Paradigms
variables
functions (methods in Java)
Loop statements
Conditional statements
/*There are NOT
classes
Classes and
Objects will
appear in C++
*/
// Different from
// Java
Array
Structures
Pointers
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 6
Outline
1. Getting started with Language C
2. Primitive data types, arrays (and strings)
3. Pointers
4. typedef, enum and struct type
5. Functions calls and parameter passing
1. Getting Started
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 8
We Need a Compiler
• Microsoft Visual Studio for C/C++
View instructions on Blackboard
• Online Compiler for C/C++
https://www.onlinegdb.com/online_c_compiler
• Dev-C++ 5
http://www.bloodshed.net/devcpp.html
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 9
Reference
• Textbook
Section 2.1 to 2.5 and 2.7
Optional 2.6 (files), 2.7 (recursion). – not included in the exam
• The Programming Language C by Kernighan and Ritchie
https://archive.org/details/TheCProgrammingLanguageFirstEdition
• Learning C programming
https://www.tutorialspoint.com/cprogramming/cprogramming_tutorial.pdf
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 10
Anatomy of a Program in C
• The parts (components) of a C program are called functions.
• There are built-in functions that exist in libraries and user defined
functions that are written by the programmers.
• You can declare variables inside and outside functions. They are
called local variables and global variables, respectively.
• And, a program in C must contain exactly one main( ) function.
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 11
Getting Started
1. Comments are identical in Java
2. #include is equivalent to import
3. Libraries are *.h files
4. There are not classes
5. Methods are called functions.
6. Global variables, local
variables, and parameters.
7. Most of the lexical, syntactical,
and semantical rules are as you
know from your Java courses
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 12
main()
8. Like Java, main( ) is the entry point
for program execution.
But, (1) C allows void or int as
type for main; (2) C allows empty
parameters or two parameters for
main. This are correct:
• void main () {
}
• void main (int argc, char *argv [ ]) { }
• int main() {return 0;}
• main() {return 0;} // if there is not a
type, C apply as default int
• int main (int argc, char *argv [ ]) { }
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 13
main()
8. Like Java, main( ) is the entry point
for program execution.
But, (1) C allows void or int as
type for main; (2) C allows empty
parameters or two parameters for
main. This are correct:
• void main () {
}
• void main (int argc, char *argv [ ]) { }
• int main() {return 0;}
• main() {return 0;} // if there is not a
type, C apply as default int
• int main (int argc, char *argv [ ]) { }
public static void main(String [] args) {
}
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 14
Output
printf (control sequence, expressions);
• The control sequence includes a
constant string to be printed, e.g.,
"Result: ", and control symbols to be
used to convert variables from their
numeric values that are stored in the
computer to printing format.
• The expressions is the list of
expressions whose values are to be
printed out. Each expression is
separated by a comma. This is
optional.
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 15
Output
printf (control sequence, expressions);
• The control sequence includes a
constant string to be printed, e.g.,
"Result: ", and control symbols to be
used to convert variables from their
numeric values that are stored in the
computer to printing format.
• The expressions is the list of
expressions whose values are to be
printed out. Each expression is
separated by a comma.
%d for integer
%f for floating point
%c for character
%s for string of characters
%p address
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 16
Output
printf (control sequence, expressions);
• The control sequence includes a
constant string to be printed, e.g.,
"Result: ", and control symbols to be
used to convert variables from their
numeric values that are stored in the
computer to printing format.
• The expressions is the list of
expressions whose values are to be
printed out. Each expression is
separated by a comma. This is
optional.
// Java
int x = 5;
float y = 10.3f;
System.out.println("hello " + x + " bye " + y);
// C
int x = 5;
float y = 10.3;
printf("hello %d bye %f", x, y);
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 17
#include <stdio.h>
void main () {
int i, n = 5;
printf("Hi, please enter an integer: ");
// input: scanf (control sequence, &variable1, ... &variablen);
// &variable: address of the variable.
scanf("%d", &i); // input function
if (i > n)
n = n + i;
else
n = n - i;
printf("i = %d, n = %dn", i, n); //output function
}
Input
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 18
Control Statements
These that you know, work in the same way
• for, while, do/while
• if/else, switch
But, there are not boolean values. Zero is false and any other number is true.
The following program is correct and print “Hello”
CSE240 – Introduction to Programming Languages
Javier Gonzalez-Sanchez
javiergs@asu.edu
Fall 2017
Disclaimer. These slides can only be used as study material for the class CSE240 at ASU. They cannot be distributed or used for another purpose.

More Related Content

What's hot

Increment and Decrement operators in C++
Increment and Decrement operators in C++Increment and Decrement operators in C++
Increment and Decrement operators in C++Neeru Mittal
 
C programming function
C  programming functionC  programming function
C programming functionargusacademy
 
Input output statement in C
Input output statement in CInput output statement in C
Input output statement in CMuthuganesh S
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c languagetanmaymodi4
 
Global variables, sorting static variables,function and arrays,
Global variables, sorting static variables,function and arrays,Global variables, sorting static variables,function and arrays,
Global variables, sorting static variables,function and arrays,Ahmad55ali
 
Precedence and associativity (Computer programming and utilization)
Precedence and associativity (Computer programming and utilization)Precedence and associativity (Computer programming and utilization)
Precedence and associativity (Computer programming and utilization)Digvijaysinh Gohil
 
VTU PCD Model Question Paper - Programming in C
VTU PCD Model Question Paper - Programming in CVTU PCD Model Question Paper - Programming in C
VTU PCD Model Question Paper - Programming in CSyed Mustafa
 
function in c
function in cfunction in c
function in csubam3
 
C operators
C operatorsC operators
C operatorsGPERI
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’eShikshak
 
Types of operators in C
Types of operators in CTypes of operators in C
Types of operators in CPrabhu Govind
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branchingSaranya saran
 

What's hot (20)

Increment and Decrement operators in C++
Increment and Decrement operators in C++Increment and Decrement operators in C++
Increment and Decrement operators in C++
 
C programming function
C  programming functionC  programming function
C programming function
 
Input output statement in C
Input output statement in CInput output statement in C
Input output statement in C
 
201801 CSE240 Lecture 07
201801 CSE240 Lecture 07201801 CSE240 Lecture 07
201801 CSE240 Lecture 07
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
 
Global variables, sorting static variables,function and arrays,
Global variables, sorting static variables,function and arrays,Global variables, sorting static variables,function and arrays,
Global variables, sorting static variables,function and arrays,
 
Precedence and associativity (Computer programming and utilization)
Precedence and associativity (Computer programming and utilization)Precedence and associativity (Computer programming and utilization)
Precedence and associativity (Computer programming and utilization)
 
C operator and expression
C operator and expressionC operator and expression
C operator and expression
 
Operators
OperatorsOperators
Operators
 
VTU PCD Model Question Paper - Programming in C
VTU PCD Model Question Paper - Programming in CVTU PCD Model Question Paper - Programming in C
VTU PCD Model Question Paper - Programming in C
 
Fucntions & Pointers in C
Fucntions & Pointers in CFucntions & Pointers in C
Fucntions & Pointers in C
 
function in c
function in cfunction in c
function in c
 
C operators
C operatorsC operators
C operators
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’
 
What is c
What is cWhat is c
What is c
 
Function in c
Function in cFunction in c
Function in c
 
Programming in C
Programming in CProgramming in C
Programming in C
 
C Building Blocks
C Building Blocks C Building Blocks
C Building Blocks
 
Types of operators in C
Types of operators in CTypes of operators in C
Types of operators in C
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
 

Similar to 201801 CSE240 Lecture 06

Basics of c Nisarg Patel
Basics of c Nisarg PatelBasics of c Nisarg Patel
Basics of c Nisarg PatelTechNGyan
 
Programming Fundamentals Functions in C and types
Programming Fundamentals  Functions in C  and typesProgramming Fundamentals  Functions in C  and types
Programming Fundamentals Functions in C and typesimtiazalijoono
 
Functions IN CPROGRAMMING OF ENGINEERING.pptx
Functions IN CPROGRAMMING OF ENGINEERING.pptxFunctions IN CPROGRAMMING OF ENGINEERING.pptx
Functions IN CPROGRAMMING OF ENGINEERING.pptxvanshhans21102005
 
C++ unit-1-part-11
C++ unit-1-part-11C++ unit-1-part-11
C++ unit-1-part-11Jadavsejal
 
MCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit Dubey
MCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit DubeyMCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit Dubey
MCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit Dubeykiranrajat
 
Esoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programmingEsoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programmingRasan Samarasinghe
 
C programming language
C programming languageC programming language
C programming languageAbin Rimal
 
U19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).pptU19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).pptManivannan837728
 
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...RSathyaPriyaCSEKIOT
 
C programming language tutorial
C programming language tutorialC programming language tutorial
C programming language tutorialSURBHI SAROHA
 

Similar to 201801 CSE240 Lecture 06 (20)

Structure of a C program
Structure of a C programStructure of a C program
Structure of a C program
 
C programming
C programmingC programming
C programming
 
Basics of c Nisarg Patel
Basics of c Nisarg PatelBasics of c Nisarg Patel
Basics of c Nisarg Patel
 
Programming Fundamentals Functions in C and types
Programming Fundamentals  Functions in C  and typesProgramming Fundamentals  Functions in C  and types
Programming Fundamentals Functions in C and types
 
Functions IN CPROGRAMMING OF ENGINEERING.pptx
Functions IN CPROGRAMMING OF ENGINEERING.pptxFunctions IN CPROGRAMMING OF ENGINEERING.pptx
Functions IN CPROGRAMMING OF ENGINEERING.pptx
 
4th unit full
4th unit full4th unit full
4th unit full
 
C++ unit-1-part-11
C++ unit-1-part-11C++ unit-1-part-11
C++ unit-1-part-11
 
MCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit Dubey
MCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit DubeyMCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit Dubey
MCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit Dubey
 
Functions struct&union
Functions struct&unionFunctions struct&union
Functions struct&union
 
Esoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programmingEsoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programming
 
C programming language
C programming languageC programming language
C programming language
 
U19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).pptU19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).ppt
 
unit_2 (1).pptx
unit_2 (1).pptxunit_2 (1).pptx
unit_2 (1).pptx
 
CP Handout#2
CP Handout#2CP Handout#2
CP Handout#2
 
ANSI C Macros
ANSI C MacrosANSI C Macros
ANSI C Macros
 
Pc module1
Pc module1Pc module1
Pc module1
 
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
 
C programming language tutorial
C programming language tutorialC programming language tutorial
C programming language tutorial
 
C programming
C programmingC programming
C programming
 
Basic of C Programming | 2022 Updated | By Shamsul H. Ansari
Basic of C Programming | 2022 Updated | By Shamsul H. AnsariBasic of C Programming | 2022 Updated | By Shamsul H. Ansari
Basic of C Programming | 2022 Updated | By Shamsul H. Ansari
 

More from Javier Gonzalez-Sanchez (20)

201804 SER332 Lecture 01
201804 SER332 Lecture 01201804 SER332 Lecture 01
201804 SER332 Lecture 01
 
201801 SER332 Lecture 03
201801 SER332 Lecture 03201801 SER332 Lecture 03
201801 SER332 Lecture 03
 
201801 SER332 Lecture 04
201801 SER332 Lecture 04201801 SER332 Lecture 04
201801 SER332 Lecture 04
 
201801 SER332 Lecture 02
201801 SER332 Lecture 02201801 SER332 Lecture 02
201801 SER332 Lecture 02
 
201801 CSE240 Lecture 26
201801 CSE240 Lecture 26201801 CSE240 Lecture 26
201801 CSE240 Lecture 26
 
201801 CSE240 Lecture 25
201801 CSE240 Lecture 25201801 CSE240 Lecture 25
201801 CSE240 Lecture 25
 
201801 CSE240 Lecture 24
201801 CSE240 Lecture 24201801 CSE240 Lecture 24
201801 CSE240 Lecture 24
 
201801 CSE240 Lecture 23
201801 CSE240 Lecture 23201801 CSE240 Lecture 23
201801 CSE240 Lecture 23
 
201801 CSE240 Lecture 22
201801 CSE240 Lecture 22201801 CSE240 Lecture 22
201801 CSE240 Lecture 22
 
201801 CSE240 Lecture 21
201801 CSE240 Lecture 21201801 CSE240 Lecture 21
201801 CSE240 Lecture 21
 
201801 CSE240 Lecture 20
201801 CSE240 Lecture 20201801 CSE240 Lecture 20
201801 CSE240 Lecture 20
 
201801 CSE240 Lecture 19
201801 CSE240 Lecture 19201801 CSE240 Lecture 19
201801 CSE240 Lecture 19
 
201801 CSE240 Lecture 18
201801 CSE240 Lecture 18201801 CSE240 Lecture 18
201801 CSE240 Lecture 18
 
201801 CSE240 Lecture 17
201801 CSE240 Lecture 17201801 CSE240 Lecture 17
201801 CSE240 Lecture 17
 
201801 CSE240 Lecture 16
201801 CSE240 Lecture 16201801 CSE240 Lecture 16
201801 CSE240 Lecture 16
 
201801 CSE240 Lecture 15
201801 CSE240 Lecture 15201801 CSE240 Lecture 15
201801 CSE240 Lecture 15
 
201801 CSE240 Lecture 14
201801 CSE240 Lecture 14201801 CSE240 Lecture 14
201801 CSE240 Lecture 14
 
201801 CSE240 Lecture 13
201801 CSE240 Lecture 13201801 CSE240 Lecture 13
201801 CSE240 Lecture 13
 
201801 CSE240 Lecture 12
201801 CSE240 Lecture 12201801 CSE240 Lecture 12
201801 CSE240 Lecture 12
 
201801 CSE240 Lecture 11
201801 CSE240 Lecture 11201801 CSE240 Lecture 11
201801 CSE240 Lecture 11
 

Recently uploaded

Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 

Recently uploaded (20)

Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 

201801 CSE240 Lecture 06

  • 1. CSE240 – Introduction to Programming Languages Lecture 06: Programming with C Javier Gonzalez-Sanchez javiergs@asu.edu javiergs.engineering.asu.edu Office Hours: By appointment
  • 2. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 2 Imperative Paradigm Fully specified and fully controlled manipulation of named data in a stepwise fashion. which means that: Programs are algorithmic in nature: do this, then that, then repeat this ten times Focuses on how rather than what. variables functions (methods in Java) Loop statements Conditional statements
  • 3. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 3 Paradigms variables functions (methods in Java) Loop statements Conditional statements
  • 4. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 4 Paradigms variables functions (methods in Java) Loop statements Conditional statements // Different from // Java Arrays Structs Pointers
  • 5. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 5 Paradigms variables functions (methods in Java) Loop statements Conditional statements /*There are NOT classes Classes and Objects will appear in C++ */ // Different from // Java Array Structures Pointers
  • 6. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 6 Outline 1. Getting started with Language C 2. Primitive data types, arrays (and strings) 3. Pointers 4. typedef, enum and struct type 5. Functions calls and parameter passing
  • 8. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 8 We Need a Compiler • Microsoft Visual Studio for C/C++ View instructions on Blackboard • Online Compiler for C/C++ https://www.onlinegdb.com/online_c_compiler • Dev-C++ 5 http://www.bloodshed.net/devcpp.html
  • 9. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 9 Reference • Textbook Section 2.1 to 2.5 and 2.7 Optional 2.6 (files), 2.7 (recursion). – not included in the exam • The Programming Language C by Kernighan and Ritchie https://archive.org/details/TheCProgrammingLanguageFirstEdition • Learning C programming https://www.tutorialspoint.com/cprogramming/cprogramming_tutorial.pdf
  • 10. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 10 Anatomy of a Program in C • The parts (components) of a C program are called functions. • There are built-in functions that exist in libraries and user defined functions that are written by the programmers. • You can declare variables inside and outside functions. They are called local variables and global variables, respectively. • And, a program in C must contain exactly one main( ) function.
  • 11. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 11 Getting Started 1. Comments are identical in Java 2. #include is equivalent to import 3. Libraries are *.h files 4. There are not classes 5. Methods are called functions. 6. Global variables, local variables, and parameters. 7. Most of the lexical, syntactical, and semantical rules are as you know from your Java courses
  • 12. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 12 main() 8. Like Java, main( ) is the entry point for program execution. But, (1) C allows void or int as type for main; (2) C allows empty parameters or two parameters for main. This are correct: • void main () { } • void main (int argc, char *argv [ ]) { } • int main() {return 0;} • main() {return 0;} // if there is not a type, C apply as default int • int main (int argc, char *argv [ ]) { }
  • 13. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 13 main() 8. Like Java, main( ) is the entry point for program execution. But, (1) C allows void or int as type for main; (2) C allows empty parameters or two parameters for main. This are correct: • void main () { } • void main (int argc, char *argv [ ]) { } • int main() {return 0;} • main() {return 0;} // if there is not a type, C apply as default int • int main (int argc, char *argv [ ]) { } public static void main(String [] args) { }
  • 14. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 14 Output printf (control sequence, expressions); • The control sequence includes a constant string to be printed, e.g., "Result: ", and control symbols to be used to convert variables from their numeric values that are stored in the computer to printing format. • The expressions is the list of expressions whose values are to be printed out. Each expression is separated by a comma. This is optional.
  • 15. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 15 Output printf (control sequence, expressions); • The control sequence includes a constant string to be printed, e.g., "Result: ", and control symbols to be used to convert variables from their numeric values that are stored in the computer to printing format. • The expressions is the list of expressions whose values are to be printed out. Each expression is separated by a comma. %d for integer %f for floating point %c for character %s for string of characters %p address
  • 16. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 16 Output printf (control sequence, expressions); • The control sequence includes a constant string to be printed, e.g., "Result: ", and control symbols to be used to convert variables from their numeric values that are stored in the computer to printing format. • The expressions is the list of expressions whose values are to be printed out. Each expression is separated by a comma. This is optional. // Java int x = 5; float y = 10.3f; System.out.println("hello " + x + " bye " + y); // C int x = 5; float y = 10.3; printf("hello %d bye %f", x, y);
  • 17. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 17 #include <stdio.h> void main () { int i, n = 5; printf("Hi, please enter an integer: "); // input: scanf (control sequence, &variable1, ... &variablen); // &variable: address of the variable. scanf("%d", &i); // input function if (i > n) n = n + i; else n = n - i; printf("i = %d, n = %dn", i, n); //output function } Input
  • 18. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 18 Control Statements These that you know, work in the same way • for, while, do/while • if/else, switch But, there are not boolean values. Zero is false and any other number is true. The following program is correct and print “Hello”
  • 19. CSE240 – Introduction to Programming Languages Javier Gonzalez-Sanchez javiergs@asu.edu Fall 2017 Disclaimer. These slides can only be used as study material for the class CSE240 at ASU. They cannot be distributed or used for another purpose.