SlideShare ist ein Scribd-Unternehmen logo
1 von 18
Chapter 2 - Introduction to C Programming Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers 2.4 Memory Concepts 2.5 Arithmetic in C 2.6 Decision Making: Equality and Relational Operators
2.1 Introduction ,[object Object],[object Object],[object Object],[object Object],[object Object]
2.2 A Simple C Program: Printing a Line of Text ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Welcome to C!  1 /* Fig. 2.1: fig02_01.c 2   A first program in C */ 3 #include  <stdio.h> 4 5 int  main() 6 { 7   printf( &quot;Welcome to C!&quot; ); 8 9   return  0; 10 }
2.2 A Simple C Program: Printing a Line of Text ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
2.2 A Simple C Program: Printing a Line of Text ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
2.2 A Simple C Program: Printing a Line of Text ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
1. Initialize variables 2. Input 2.1 Sum 3. Print Program Output Enter first integer 45 Enter second integer 72 Sum is 117   1 /* Fig. 2.5: fig02_05.c 2   Addition program */ 3 #include  <stdio.h> 4 5 int  main() 6 { 7   int  integer1, integer2, sum;  /* declaration */ 8 9   printf( &quot;Enter first integer&quot; );  /* prompt */ 10   scanf( &quot;%d&quot;, &integer1 );  /* read an integer */ 11   printf( &quot;Enter second integer&quot; );  /* prompt */ 12   scanf( &quot;%d&quot;, &integer2 );  /* read an integer */ 13   sum = integer1 + integer2;  /* assignment of sum */ 14   printf( &quot;Sum is %d&quot;, sum );  /* print sum */ 15 16   return  0;  /* indicate that program ended successfully */ 17 }
2.3 Another Simple C Program: Adding Two Integers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
2.3 Another Simple C Program: Adding Two Integers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
2.3 Another Simple C Program: Adding Two Integers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
2.4 Memory Concepts ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],integer1 45
2.5  Arithmetic ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
2.5  Arithmetic ,[object Object],[object Object]
2.6 Decision Making: Equality and Relational Operators ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
2.6 Decision Making: Equality and Relational Operators
2.6 Decision Making: Equality and Relational Operators
1. Declare variables 2. Input 2.1  if  statements 3. Print 1 /* Fig. 2.13: fig02_13.c 2   Using if statements, relational   3   operators, and equality operators */ 4 #include  <stdio.h> 5 6 int  main() 7 { 8   int  num1, num2; 9   10   printf( &quot;Enter two integers, and I will tell you&quot; ); 11   printf( &quot;the relationships they satisfy: &quot; ); 12   scanf( &quot;%d%d&quot;, &num1, &num2  );  /* read two integers */ 13   14   if  ( num1 == num2 )  15   printf( &quot;%d is equal to %d&quot;, num1, num2 ); 16 17   if  ( num1 != num2 )  18   printf( &quot;%d is not equal to %d&quot;, num1, num2 ); 19 20   if  ( num1 < num2 )  21   printf( &quot;%d is less than %d&quot;, num1, num2 ); 22 23   if  ( num1 > num2 )  24   printf( &quot;%d is greater than %d&quot;, num1, num2 ); 25 26   if  ( num1 <= num2 )  27   printf( &quot;%d is less than or equal to %d&quot;,  28   num1, num2 );
3.1 Exit  main Program Output Enter two integers, and I will tell you  the relationships they satisfy: 3 7 3 is not equal to 7 3 is less than 7 3 is less than or equal to 7   Enter two integers, and I will tell you  the relationships they satisfy: 22 12 22 is not equal to 12 22 is greater than 12 22 is greater than or equal to 12   29 30   if  ( num1 >= num2 )  31   printf( &quot;%d is greater than or equal to %d&quot;,  32   num1, num2 ); 33 34   return  0;  /* indicate program ended successfully */ 35 }

Weitere ähnliche Inhalte

Was ist angesagt?

Ch1 principles of software development
Ch1 principles of software developmentCh1 principles of software development
Ch1 principles of software developmentHattori Sidek
 
Overview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya JyothiOverview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya JyothiSowmya Jyothi
 
Introduction to flowchart
Introduction to flowchartIntroduction to flowchart
Introduction to flowchartJordan Delacruz
 
Pseudocode algorithim flowchart
Pseudocode algorithim flowchartPseudocode algorithim flowchart
Pseudocode algorithim flowchartfika sweety
 
Unit 3 Foc
Unit  3 FocUnit  3 Foc
Unit 3 FocJAYA
 
Computer experiments 1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
Computer experiments   1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branchComputer experiments   1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
Computer experiments 1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branchSAKSHIGAWADE2
 
C programming tokens & error types
C  programming tokens & error typesC  programming tokens & error types
C programming tokens & error typesargusacademy
 

Was ist angesagt? (19)

Ch1 principles of software development
Ch1 principles of software developmentCh1 principles of software development
Ch1 principles of software development
 
Ch3 repetition
Ch3 repetitionCh3 repetition
Ch3 repetition
 
Overview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya JyothiOverview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya Jyothi
 
Casa lab manual
Casa lab manualCasa lab manual
Casa lab manual
 
Chap 3 c++
Chap 3 c++Chap 3 c++
Chap 3 c++
 
Basics of c++
Basics of c++ Basics of c++
Basics of c++
 
Flowcharts
FlowchartsFlowcharts
Flowcharts
 
C Programming Unit-1
C Programming Unit-1C Programming Unit-1
C Programming Unit-1
 
Introduction to flowchart
Introduction to flowchartIntroduction to flowchart
Introduction to flowchart
 
C Introduction
C IntroductionC Introduction
C Introduction
 
Pseudocode algorithim flowchart
Pseudocode algorithim flowchartPseudocode algorithim flowchart
Pseudocode algorithim flowchart
 
algo
algoalgo
algo
 
Unit 3 Foc
Unit  3 FocUnit  3 Foc
Unit 3 Foc
 
Computer experiments 1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
Computer experiments   1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branchComputer experiments   1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
Computer experiments 1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
 
Vb (1)
Vb (1)Vb (1)
Vb (1)
 
keyword
keywordkeyword
keyword
 
Learning the C Language
Learning the C LanguageLearning the C Language
Learning the C Language
 
C programming tokens & error types
C  programming tokens & error typesC  programming tokens & error types
C programming tokens & error types
 
C Programming Unit-2
C Programming Unit-2C Programming Unit-2
C Programming Unit-2
 

Ähnlich wie C chap02

C++ Overview
C++ OverviewC++ Overview
C++ Overviewkelleyc3
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to cHattori Sidek
 
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
 
Lec1_EENG112-Introduction.pdf
Lec1_EENG112-Introduction.pdfLec1_EENG112-Introduction.pdf
Lec1_EENG112-Introduction.pdfShwetaSaharan8
 
Basics Of C++.pptx
Basics Of C++.pptxBasics Of C++.pptx
Basics Of C++.pptxDineshDhuri4
 
2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2Don Dooley
 
03 intro to vb programming
03 intro to vb programming03 intro to vb programming
03 intro to vb programmingJomel Penalba
 
Visual Basic Programming
Visual Basic ProgrammingVisual Basic Programming
Visual Basic ProgrammingOsama Yaseen
 
CHAPTER-2.ppt
CHAPTER-2.pptCHAPTER-2.ppt
CHAPTER-2.pptTekle12
 
Introduction to C++ lecture ************
Introduction to C++ lecture ************Introduction to C++ lecture ************
Introduction to C++ lecture ************Emad Helal
 
Csc1100 lecture03 ch03-pt2-s14
Csc1100 lecture03 ch03-pt2-s14Csc1100 lecture03 ch03-pt2-s14
Csc1100 lecture03 ch03-pt2-s14IIUM
 
Csc1100 lecture03 ch03-pt2-s14
Csc1100 lecture03 ch03-pt2-s14Csc1100 lecture03 ch03-pt2-s14
Csc1100 lecture03 ch03-pt2-s14IIUM
 

Ähnlich wie C chap02 (20)

Chapter2
Chapter2Chapter2
Chapter2
 
C++ Overview
C++ OverviewC++ Overview
C++ Overview
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to c
 
C Intro.ppt
C Intro.pptC Intro.ppt
C Intro.ppt
 
Unit-IV.pptx
Unit-IV.pptxUnit-IV.pptx
Unit-IV.pptx
 
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...
 
Lec1_EENG112-Introduction.pdf
Lec1_EENG112-Introduction.pdfLec1_EENG112-Introduction.pdf
Lec1_EENG112-Introduction.pdf
 
Basics Of C++.pptx
Basics Of C++.pptxBasics Of C++.pptx
Basics Of C++.pptx
 
2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2
 
C programming
C programmingC programming
C programming
 
03 intro to vb programming
03 intro to vb programming03 intro to vb programming
03 intro to vb programming
 
Chapter03 Ppt
Chapter03 PptChapter03 Ppt
Chapter03 Ppt
 
Visual Basic Programming
Visual Basic ProgrammingVisual Basic Programming
Visual Basic Programming
 
UNIT-II CP DOC.docx
UNIT-II CP DOC.docxUNIT-II CP DOC.docx
UNIT-II CP DOC.docx
 
CHAPTER-2.ppt
CHAPTER-2.pptCHAPTER-2.ppt
CHAPTER-2.ppt
 
First c program
First c programFirst c program
First c program
 
Introduction to C++ lecture ************
Introduction to C++ lecture ************Introduction to C++ lecture ************
Introduction to C++ lecture ************
 
keyword
keywordkeyword
keyword
 
Csc1100 lecture03 ch03-pt2-s14
Csc1100 lecture03 ch03-pt2-s14Csc1100 lecture03 ch03-pt2-s14
Csc1100 lecture03 ch03-pt2-s14
 
Csc1100 lecture03 ch03-pt2-s14
Csc1100 lecture03 ch03-pt2-s14Csc1100 lecture03 ch03-pt2-s14
Csc1100 lecture03 ch03-pt2-s14
 

Mehr von Khan Rahimeen

Mehr von Khan Rahimeen (8)

Mysqlppt3510
Mysqlppt3510Mysqlppt3510
Mysqlppt3510
 
Mysql2
Mysql2Mysql2
Mysql2
 
Lab 4 excel basics
Lab 4 excel basicsLab 4 excel basics
Lab 4 excel basics
 
Introductionto excel2007
Introductionto excel2007Introductionto excel2007
Introductionto excel2007
 
C tutorial
C tutorialC tutorial
C tutorial
 
C
CC
C
 
5 intro to networking
5 intro to networking5 intro to networking
5 intro to networking
 
1 introduction-to-computer-networking
1 introduction-to-computer-networking1 introduction-to-computer-networking
1 introduction-to-computer-networking
 

Kürzlich hochgeladen

What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 

Kürzlich hochgeladen (20)

What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 

C chap02

  • 1. Chapter 2 - Introduction to C Programming Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers 2.4 Memory Concepts 2.5 Arithmetic in C 2.6 Decision Making: Equality and Relational Operators
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7. 1. Initialize variables 2. Input 2.1 Sum 3. Print Program Output Enter first integer 45 Enter second integer 72 Sum is 117 1 /* Fig. 2.5: fig02_05.c 2 Addition program */ 3 #include <stdio.h> 4 5 int main() 6 { 7 int integer1, integer2, sum; /* declaration */ 8 9 printf( &quot;Enter first integer&quot; ); /* prompt */ 10 scanf( &quot;%d&quot;, &integer1 ); /* read an integer */ 11 printf( &quot;Enter second integer&quot; ); /* prompt */ 12 scanf( &quot;%d&quot;, &integer2 ); /* read an integer */ 13 sum = integer1 + integer2; /* assignment of sum */ 14 printf( &quot;Sum is %d&quot;, sum ); /* print sum */ 15 16 return 0; /* indicate that program ended successfully */ 17 }
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15. 2.6 Decision Making: Equality and Relational Operators
  • 16. 2.6 Decision Making: Equality and Relational Operators
  • 17. 1. Declare variables 2. Input 2.1 if statements 3. Print 1 /* Fig. 2.13: fig02_13.c 2 Using if statements, relational 3 operators, and equality operators */ 4 #include <stdio.h> 5 6 int main() 7 { 8 int num1, num2; 9 10 printf( &quot;Enter two integers, and I will tell you&quot; ); 11 printf( &quot;the relationships they satisfy: &quot; ); 12 scanf( &quot;%d%d&quot;, &num1, &num2 ); /* read two integers */ 13 14 if ( num1 == num2 ) 15 printf( &quot;%d is equal to %d&quot;, num1, num2 ); 16 17 if ( num1 != num2 ) 18 printf( &quot;%d is not equal to %d&quot;, num1, num2 ); 19 20 if ( num1 < num2 ) 21 printf( &quot;%d is less than %d&quot;, num1, num2 ); 22 23 if ( num1 > num2 ) 24 printf( &quot;%d is greater than %d&quot;, num1, num2 ); 25 26 if ( num1 <= num2 ) 27 printf( &quot;%d is less than or equal to %d&quot;, 28 num1, num2 );
  • 18. 3.1 Exit main Program Output Enter two integers, and I will tell you the relationships they satisfy: 3 7 3 is not equal to 7 3 is less than 7 3 is less than or equal to 7 Enter two integers, and I will tell you the relationships they satisfy: 22 12 22 is not equal to 12 22 is greater than 12 22 is greater than or equal to 12 29 30 if ( num1 >= num2 ) 31 printf( &quot;%d is greater than or equal to %d&quot;, 32 num1, num2 ); 33 34 return 0; /* indicate program ended successfully */ 35 }