SlideShare a Scribd company logo
With : Rumman Ansari
Operators Precedence in C
Category Operator Associativity
Postfix () [] -> . ++ - - Left to right
Unary + - ! ~ ++ - - (type)* & sizeof Right to left
Multiplicative * / % Left to right
Additive + - Left to right
Shift << >> Left to right
Relational < <= > >= Left to right
Equality == != Left to right
Bitwise AND & Left to right
Bitwise XOR ^ Left to right
Bitwise OR | Left to right
Logical AND && Left to right
Logical OR || Left to right
Conditional ?: Right to left
Assignment = += -= *= /= %=>>= <<= &=
^= |=
Right to left
Comma , Left to right
#include<stdio.h>
void main()
{
int x;
x=-3+4*5-6; printf("%d n",x);
x=3+(4%5)-6; printf("%d n",x);
x=-3*4%-6/5; printf("%d n",x);
x=(7+6)%5/2; printf("%d n",x);
}
11
1
0
1
Program
Output
#include<stdio.h>
void main()
{
int x=2,y,z;
x*=3+2; printf("%d n",x);
x*=y=z=4; printf("%d n",x);
x=y==z; printf("%d n",x);
x==(y=z); printf("%d n",x);
}
10
40
1
1
Program
Output
#include<stdio.h>
void main()
{
int x,y,z;
x=2; y=1; z=9;
x= x&&y||z;
printf("%d n",x);
printf("%d
n",x||!y&&z);
x=y=1;
z=x++ -1;
printf("%d n",x);
printf("%d n",z);
z+=-x ++ + ++y ;
printf("%d n",x);
printf("%d n",z);
}
Program Output
1
1
2
0
3
0
Decision Making
Statement Description
if statement An if statement consists of a boolean expression
followed by one or more statements.
if...else statement An if statement can be followed by an
optional else statement, which executes when
the boolean expression is false.
nested if statements You can use one if or else if statement inside
another if orelse if statement(s).
switch statement A switch statement allows a variable to be tested
for equality against a list of values.
nested switch
statements
You can use one switch statement inside
another switchstatement(s).
if
#include <stdio.h>
int main ()
{
/* local variable definition */
int a = 10;
/* check the boolean condition using if statement */
if( a < 20 )
{
/* if condition is true then print the following */
printf("a is less than 20n" );
}
printf("value of a is : %dn", a);
return 0;
}
Flow Diagram:
1
if...else statement
Syntax:
if(boolean_expression)
{
/* statement(s) will execute if the boolean expression is true */
}
else
{
/* statement(s) will execute if the boolean expression is false */
}
Flow Diagram:
2
#include <stdio.h>
int main ()
{
/* local variable definition */
int a = 100;
/* check the boolean condition */
if( a < 20 )
{
/* if condition is true then print the following */
printf("a is less than 20n" );
}
else
{
/* if condition is false then print the following */
printf("a is not less than 20n" );
}
printf("value of a is : %dn", a);
return 0;
}
if...else if...else Statement
Syntax:
if(boolean_expression 1)
{
/* Executes when the boolean expression 1 is true */
}
else if( boolean_expression 2)
{
/* Executes when the boolean expression 2 is true */
}
else if( boolean_expression 3)
{
/* Executes when the boolean expression 3 is true */
}
else
{
/* executes when the none of the above condition is true */
}
3
Example #include <stdio.h>
int main ()
{
/* local variable definition */
int a = 100;
/* check the boolean condition */
if( a == 10 )
{
/* if condition is true then print the following */
printf("Value of a is 10n" );
}
else if( a == 20 )
{
/* if else if condition is true */
printf("Value of a is 20n" );
}
else if( a == 30 )
{
/* if else if condition is true */
printf("Value of a is 30n" );
}
else
{
/* if none of the conditions is true */
printf("None of the values is matchingn" );
}
printf("Exact value of a is: %dn", a );
return 0;
}
nested if statements4
Syntax:
if( boolean_expression 1)
{
/* Executes when the boolean expression 1 is true */
if(boolean_expression 2)
{
/* Executes when the boolean expression 2 is true */
}
}
Example
#include <stdio.h>
int main ()
{
/* local variable definition */
int a = 100;
int b = 200;
/* check the boolean condition */
if( a == 100 )
{
/* if condition is true then check the following
*/
if( b == 200 )
{
/* if condition is true then print the following */
printf("Value of a is 100 and b is 200n" );
}
}
printf("Exact value of a is : %dn", a );
printf("Exact value of b is : %dn", b );
return 0;
}
switch statement
Syntax: switch(expression){
case constant-expression :
statement(s);
break; /* optional */
case constant-expression :
statement(s);
break; /* optional */
/* you can have any number of case statements */
default : /* Optional */
statement(s);
}
switch ( integer expression )
{
case constant 1 :
do this ;
case constant 2 :
do this ;
case constant 3 :
do this ;
default :
do this ;
}
5
Flow diagram
Example
#include <stdio.h>
int main ()
{
/* local variable definition */
char grade = 'B';
switch(grade)
{
case 'A' :
printf("Excellent!n" );
break;
case 'B' :
case 'C' :
printf("Well donen" );
break;
case 'D' :
printf("You passedn" );
break;
case 'F' :
printf("Better try againn" );
break;
default :
printf("Invalid graden" );
}
printf("Your grade is %cn", grade );
return 0;
}
nested switch statements
Syntax:
switch(ch1) {
case 'A':
printf("This A is part of outer switch" );
switch(ch2) {
case 'A':
printf("This A is part of inner switch" );
break;
case 'B': /* case code */
}
break;
case 'B': /* case code */
}
6
Example
#include <stdio.h>
int main ()
{
/* local variable definition */
int a = 100;
int b = 200;
switch(a) {
case 100:
printf("This is part of outer switchn", a );
switch(b) {
case 200:
printf("This is part of inner switchn", a );
}
}
printf("Exact value of a is : %dn", a );
printf("Exact value of b is : %dn", b );
return 0;
}
Ad

More Related Content

What's hot (19)

C programming
C programmingC programming
C programming
Samsil Arefin
 
7 functions
7  functions7  functions
7 functions
MomenMostafa
 
Understanding storage class using nm
Understanding storage class using nmUnderstanding storage class using nm
Understanding storage class using nm
mohamed sikander
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
Azhar Javed
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
vrgokila
 
Function basics
Function basicsFunction basics
Function basics
mohamed sikander
 
3. chapter ii
3. chapter ii3. chapter ii
3. chapter ii
Chhom Karath
 
4. chapter iii
4. chapter iii4. chapter iii
4. chapter iii
Chhom Karath
 
C tech questions
C tech questionsC tech questions
C tech questions
vijay00791
 
8 arrays and pointers
8  arrays and pointers8  arrays and pointers
8 arrays and pointers
MomenMostafa
 
9 character string &amp; string library
9  character string &amp; string library9  character string &amp; string library
9 character string &amp; string library
MomenMostafa
 
C lab programs
C lab programsC lab programs
C lab programs
Dr. Prashant Vats
 
6 c control statements branching &amp; jumping
6 c control statements branching &amp; jumping6 c control statements branching &amp; jumping
6 c control statements branching &amp; jumping
MomenMostafa
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...
ssuserd6b1fd
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]
Abhishek Sinha
 
Let us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solutionLet us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solution
rohit kumar
 
week-6x
week-6xweek-6x
week-6x
KITE www.kitecolleges.com
 
Stl algorithm-Basic types
Stl algorithm-Basic typesStl algorithm-Basic types
Stl algorithm-Basic types
mohamed sikander
 
Intro to c chapter cover 1 4
Intro to c chapter cover 1 4Intro to c chapter cover 1 4
Intro to c chapter cover 1 4
Hazwan Arif
 
Understanding storage class using nm
Understanding storage class using nmUnderstanding storage class using nm
Understanding storage class using nm
mohamed sikander
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
Azhar Javed
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
vrgokila
 
C tech questions
C tech questionsC tech questions
C tech questions
vijay00791
 
8 arrays and pointers
8  arrays and pointers8  arrays and pointers
8 arrays and pointers
MomenMostafa
 
9 character string &amp; string library
9  character string &amp; string library9  character string &amp; string library
9 character string &amp; string library
MomenMostafa
 
6 c control statements branching &amp; jumping
6 c control statements branching &amp; jumping6 c control statements branching &amp; jumping
6 c control statements branching &amp; jumping
MomenMostafa
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...
ssuserd6b1fd
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]
Abhishek Sinha
 
Let us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solutionLet us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solution
rohit kumar
 
Intro to c chapter cover 1 4
Intro to c chapter cover 1 4Intro to c chapter cover 1 4
Intro to c chapter cover 1 4
Hazwan Arif
 

Viewers also liked (19)

C Programming Language Step by Step Part 1
C Programming Language Step by Step Part 1C Programming Language Step by Step Part 1
C Programming Language Step by Step Part 1
Rumman Ansari
 
C Programming Language Step by Step Part 3
C Programming Language Step by Step Part 3C Programming Language Step by Step Part 3
C Programming Language Step by Step Part 3
Rumman Ansari
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
Abhishek Dwivedi
 
Procedural programming
Procedural programmingProcedural programming
Procedural programming
Ankit92Chitnavis
 
laporan akhir objek 1 print
laporan akhir objek 1 printlaporan akhir objek 1 print
laporan akhir objek 1 print
Utari Yolla Sundari
 
#ioleggoperché scende in campo
#ioleggoperché scende in campo#ioleggoperché scende in campo
#ioleggoperché scende in campo
Claudia Bertanza
 
Final PDF Paper 3-6-12
Final PDF Paper 3-6-12Final PDF Paper 3-6-12
Final PDF Paper 3-6-12
Geza Kmetty
 
Whistle blowing
Whistle blowingWhistle blowing
Whistle blowing
ReineM
 
分子進化の統計モデリングとモデル選択 実習編
分子進化の統計モデリングとモデル選択 実習編分子進化の統計モデリングとモデル選択 実習編
分子進化の統計モデリングとモデル選択 実習編
astanabe
 
план виховної роботи на і семестр 2014 2015 вовченко о.м.
план виховної роботи на і семестр  2014  2015 вовченко о.м.план виховної роботи на і семестр  2014  2015 вовченко о.м.
план виховної роботи на і семестр 2014 2015 вовченко о.м.
Poltava municipal lyceum #1
 
Planners-Guide---FINAL-Sept-2016-revisions
Planners-Guide---FINAL-Sept-2016-revisionsPlanners-Guide---FINAL-Sept-2016-revisions
Planners-Guide---FINAL-Sept-2016-revisions
Hilary Simmons
 
Take Your Kids to Work
Take Your Kids to WorkTake Your Kids to Work
Take Your Kids to Work
Deborah Everest-Hill HBA, Journalism Diploma
 
Lead Generation System For LinkedIn
Lead Generation System For LinkedInLead Generation System For LinkedIn
Lead Generation System For LinkedIn
Kevin Poultard
 
Energía Eólica
Energía EólicaEnergía Eólica
Energía Eólica
Tarariras HOY
 
Muhammad Qasim Zaib C.V
Muhammad Qasim Zaib C.VMuhammad Qasim Zaib C.V
Muhammad Qasim Zaib C.V
Muhammad Qasim Zaib
 
recruiting-trends-global-linkedin-2015
recruiting-trends-global-linkedin-2015recruiting-trends-global-linkedin-2015
recruiting-trends-global-linkedin-2015
Gourab Banerjee
 
історія кохання
історія коханняісторія кохання
історія кохання
Poltava municipal lyceum #1
 
правила дії під час виявлення внп
правила дії під час виявлення внпправила дії під час виявлення внп
правила дії під час виявлення внп
Poltava municipal lyceum #1
 
C Programming Language Step by Step Part 1
C Programming Language Step by Step Part 1C Programming Language Step by Step Part 1
C Programming Language Step by Step Part 1
Rumman Ansari
 
C Programming Language Step by Step Part 3
C Programming Language Step by Step Part 3C Programming Language Step by Step Part 3
C Programming Language Step by Step Part 3
Rumman Ansari
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
Abhishek Dwivedi
 
#ioleggoperché scende in campo
#ioleggoperché scende in campo#ioleggoperché scende in campo
#ioleggoperché scende in campo
Claudia Bertanza
 
Final PDF Paper 3-6-12
Final PDF Paper 3-6-12Final PDF Paper 3-6-12
Final PDF Paper 3-6-12
Geza Kmetty
 
Whistle blowing
Whistle blowingWhistle blowing
Whistle blowing
ReineM
 
分子進化の統計モデリングとモデル選択 実習編
分子進化の統計モデリングとモデル選択 実習編分子進化の統計モデリングとモデル選択 実習編
分子進化の統計モデリングとモデル選択 実習編
astanabe
 
план виховної роботи на і семестр 2014 2015 вовченко о.м.
план виховної роботи на і семестр  2014  2015 вовченко о.м.план виховної роботи на і семестр  2014  2015 вовченко о.м.
план виховної роботи на і семестр 2014 2015 вовченко о.м.
Poltava municipal lyceum #1
 
Planners-Guide---FINAL-Sept-2016-revisions
Planners-Guide---FINAL-Sept-2016-revisionsPlanners-Guide---FINAL-Sept-2016-revisions
Planners-Guide---FINAL-Sept-2016-revisions
Hilary Simmons
 
Lead Generation System For LinkedIn
Lead Generation System For LinkedInLead Generation System For LinkedIn
Lead Generation System For LinkedIn
Kevin Poultard
 
recruiting-trends-global-linkedin-2015
recruiting-trends-global-linkedin-2015recruiting-trends-global-linkedin-2015
recruiting-trends-global-linkedin-2015
Gourab Banerjee
 
правила дії під час виявлення внп
правила дії під час виявлення внпправила дії під час виявлення внп
правила дії під час виявлення внп
Poltava municipal lyceum #1
 
Ad

Similar to C Programming Language Step by Step Part 5 (20)

CONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.pptCONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.ppt
Sanjjaayyy
 
4 operators, expressions &amp; statements
4  operators, expressions &amp; statements4  operators, expressions &amp; statements
4 operators, expressions &amp; statements
MomenMostafa
 
Unit 1- PROGRAMMING IN C OPERATORS LECTURER NOTES
Unit 1- PROGRAMMING IN C OPERATORS LECTURER NOTESUnit 1- PROGRAMMING IN C OPERATORS LECTURER NOTES
Unit 1- PROGRAMMING IN C OPERATORS LECTURER NOTES
LeahRachael
 
Cquestions
Cquestions Cquestions
Cquestions
mohamed sikander
 
M2 (1).pptxisedepofengiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
M2 (1).pptxisedepofengiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiM2 (1).pptxisedepofengiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
M2 (1).pptxisedepofengiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
rakshithatan
 
control statement
control statement control statement
control statement
Kathmandu University
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5 b...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5  b...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5  b...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5 b...
ssuserd6b1fd
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
tanmaymodi4
 
Operators inc c language
Operators inc c languageOperators inc c language
Operators inc c language
Tanmay Modi
 
3 flow
3 flow3 flow
3 flow
suresh rathod
 
3 flow
3 flow3 flow
3 flow
suresh rathod
 
Pointer basics
Pointer basicsPointer basics
Pointer basics
Mohammed Sikander
 
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solutionLet us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Hazrat Bilal
 
C aptitude scribd
C aptitude scribdC aptitude scribd
C aptitude scribd
Amit Kapoor
 
Control Structures in C
Control Structures in CControl Structures in C
Control Structures in C
sana shaikh
 
C Programming
C ProgrammingC Programming
C Programming
Raj vardhan
 
Dti2143 chap 4 control statement part 2
Dti2143 chap 4 control statement part 2Dti2143 chap 4 control statement part 2
Dti2143 chap 4 control statement part 2
alish sha
 
Advanced php
Advanced phpAdvanced php
Advanced php
Anne Lee
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
JAYA
 
C – operators and expressions
C – operators and expressionsC – operators and expressions
C – operators and expressions
Chukka Nikhil Chakravarthy
 
CONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.pptCONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.ppt
Sanjjaayyy
 
4 operators, expressions &amp; statements
4  operators, expressions &amp; statements4  operators, expressions &amp; statements
4 operators, expressions &amp; statements
MomenMostafa
 
Unit 1- PROGRAMMING IN C OPERATORS LECTURER NOTES
Unit 1- PROGRAMMING IN C OPERATORS LECTURER NOTESUnit 1- PROGRAMMING IN C OPERATORS LECTURER NOTES
Unit 1- PROGRAMMING IN C OPERATORS LECTURER NOTES
LeahRachael
 
M2 (1).pptxisedepofengiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
M2 (1).pptxisedepofengiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiM2 (1).pptxisedepofengiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
M2 (1).pptxisedepofengiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
rakshithatan
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5 b...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5  b...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5  b...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5 b...
ssuserd6b1fd
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
tanmaymodi4
 
Operators inc c language
Operators inc c languageOperators inc c language
Operators inc c language
Tanmay Modi
 
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solutionLet us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Hazrat Bilal
 
C aptitude scribd
C aptitude scribdC aptitude scribd
C aptitude scribd
Amit Kapoor
 
Control Structures in C
Control Structures in CControl Structures in C
Control Structures in C
sana shaikh
 
Dti2143 chap 4 control statement part 2
Dti2143 chap 4 control statement part 2Dti2143 chap 4 control statement part 2
Dti2143 chap 4 control statement part 2
alish sha
 
Advanced php
Advanced phpAdvanced php
Advanced php
Anne Lee
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
JAYA
 
Ad

More from Rumman Ansari (20)

Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
Rumman Ansari
 
C programming exercises and solutions
C programming exercises and solutions C programming exercises and solutions
C programming exercises and solutions
Rumman Ansari
 
Java Tutorial best website
Java Tutorial best websiteJava Tutorial best website
Java Tutorial best website
Rumman Ansari
 
Java Questions and Answers
Java Questions and AnswersJava Questions and Answers
Java Questions and Answers
Rumman Ansari
 
servlet programming
servlet programmingservlet programming
servlet programming
Rumman Ansari
 
C program to write c program without using main function
C program to write c program without using main functionC program to write c program without using main function
C program to write c program without using main function
Rumman Ansari
 
Steps for c program execution
Steps for c program executionSteps for c program execution
Steps for c program execution
Rumman Ansari
 
Pointer in c program
Pointer in c programPointer in c program
Pointer in c program
Rumman Ansari
 
My first program in c, hello world !
My first program in c, hello world !My first program in c, hello world !
My first program in c, hello world !
Rumman Ansari
 
How c program execute in c program
How c program execute in c program How c program execute in c program
How c program execute in c program
Rumman Ansari
 
What is token c programming
What is token c programmingWhat is token c programming
What is token c programming
Rumman Ansari
 
What is identifier c programming
What is identifier c programmingWhat is identifier c programming
What is identifier c programming
Rumman Ansari
 
What is keyword in c programming
What is keyword in c programmingWhat is keyword in c programming
What is keyword in c programming
Rumman Ansari
 
Type casting in c programming
Type casting in c programmingType casting in c programming
Type casting in c programming
Rumman Ansari
 
C Programming Language Part 5
C Programming Language Part 5C Programming Language Part 5
C Programming Language Part 5
Rumman Ansari
 
C Programming Language Step by Step Part 2
C Programming Language Step by Step Part 2C Programming Language Step by Step Part 2
C Programming Language Step by Step Part 2
Rumman Ansari
 
Basic c programming and explanation PPT1
Basic c programming and explanation PPT1Basic c programming and explanation PPT1
Basic c programming and explanation PPT1
Rumman Ansari
 
C Programming
C ProgrammingC Programming
C Programming
Rumman Ansari
 
Tail recursion
Tail recursionTail recursion
Tail recursion
Rumman Ansari
 
Tail Recursion in data structure
Tail Recursion in data structureTail Recursion in data structure
Tail Recursion in data structure
Rumman Ansari
 
C programming exercises and solutions
C programming exercises and solutions C programming exercises and solutions
C programming exercises and solutions
Rumman Ansari
 
Java Tutorial best website
Java Tutorial best websiteJava Tutorial best website
Java Tutorial best website
Rumman Ansari
 
Java Questions and Answers
Java Questions and AnswersJava Questions and Answers
Java Questions and Answers
Rumman Ansari
 
C program to write c program without using main function
C program to write c program without using main functionC program to write c program without using main function
C program to write c program without using main function
Rumman Ansari
 
Steps for c program execution
Steps for c program executionSteps for c program execution
Steps for c program execution
Rumman Ansari
 
Pointer in c program
Pointer in c programPointer in c program
Pointer in c program
Rumman Ansari
 
My first program in c, hello world !
My first program in c, hello world !My first program in c, hello world !
My first program in c, hello world !
Rumman Ansari
 
How c program execute in c program
How c program execute in c program How c program execute in c program
How c program execute in c program
Rumman Ansari
 
What is token c programming
What is token c programmingWhat is token c programming
What is token c programming
Rumman Ansari
 
What is identifier c programming
What is identifier c programmingWhat is identifier c programming
What is identifier c programming
Rumman Ansari
 
What is keyword in c programming
What is keyword in c programmingWhat is keyword in c programming
What is keyword in c programming
Rumman Ansari
 
Type casting in c programming
Type casting in c programmingType casting in c programming
Type casting in c programming
Rumman Ansari
 
C Programming Language Part 5
C Programming Language Part 5C Programming Language Part 5
C Programming Language Part 5
Rumman Ansari
 
C Programming Language Step by Step Part 2
C Programming Language Step by Step Part 2C Programming Language Step by Step Part 2
C Programming Language Step by Step Part 2
Rumman Ansari
 
Basic c programming and explanation PPT1
Basic c programming and explanation PPT1Basic c programming and explanation PPT1
Basic c programming and explanation PPT1
Rumman Ansari
 
Tail Recursion in data structure
Tail Recursion in data structureTail Recursion in data structure
Tail Recursion in data structure
Rumman Ansari
 

Recently uploaded (20)

introduction technology technology tec.pptx
introduction technology technology tec.pptxintroduction technology technology tec.pptx
introduction technology technology tec.pptx
Iftikhar70
 
Agents chapter of Artificial intelligence
Agents chapter of Artificial intelligenceAgents chapter of Artificial intelligence
Agents chapter of Artificial intelligence
DebdeepMukherjee9
 
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdfLittle Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
gori42199
 
Slide share PPT of NOx control technologies.pptx
Slide share PPT of  NOx control technologies.pptxSlide share PPT of  NOx control technologies.pptx
Slide share PPT of NOx control technologies.pptx
vvsasane
 
Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...
Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...
Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...
AI Publications
 
Personal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.pptPersonal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.ppt
ganjangbegu579
 
Evonik Overview Visiomer Specialty Methacrylates.pdf
Evonik Overview Visiomer Specialty Methacrylates.pdfEvonik Overview Visiomer Specialty Methacrylates.pdf
Evonik Overview Visiomer Specialty Methacrylates.pdf
szhang13
 
DED KOMINFO detail engginering design gedung
DED KOMINFO detail engginering design gedungDED KOMINFO detail engginering design gedung
DED KOMINFO detail engginering design gedung
nabilarizqifadhilah1
 
Working with USDOT UTCs: From Conception to Implementation
Working with USDOT UTCs: From Conception to ImplementationWorking with USDOT UTCs: From Conception to Implementation
Working with USDOT UTCs: From Conception to Implementation
Alabama Transportation Assistance Program
 
Machine foundation notes for civil engineering students
Machine foundation notes for civil engineering studentsMachine foundation notes for civil engineering students
Machine foundation notes for civil engineering students
DYPCET
 
Prediction of Flexural Strength of Concrete Produced by Using Pozzolanic Mate...
Prediction of Flexural Strength of Concrete Produced by Using Pozzolanic Mate...Prediction of Flexural Strength of Concrete Produced by Using Pozzolanic Mate...
Prediction of Flexural Strength of Concrete Produced by Using Pozzolanic Mate...
Journal of Soft Computing in Civil Engineering
 
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
PawachMetharattanara
 
ATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ATAL 6 Days Online FDP Scheme Document 2025-26.pdfATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ssuserda39791
 
twin tower attack 2001 new york city
twin  tower  attack  2001 new  york citytwin  tower  attack  2001 new  york city
twin tower attack 2001 new york city
harishreemavs
 
2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt
rakshaiya16
 
Modeling the Influence of Environmental Factors on Concrete Evaporation Rate
Modeling the Influence of Environmental Factors on Concrete Evaporation RateModeling the Influence of Environmental Factors on Concrete Evaporation Rate
Modeling the Influence of Environmental Factors on Concrete Evaporation Rate
Journal of Soft Computing in Civil Engineering
 
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjjseninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
AjijahamadKhaji
 
Design of Variable Depth Single-Span Post.pdf
Design of Variable Depth Single-Span Post.pdfDesign of Variable Depth Single-Span Post.pdf
Design of Variable Depth Single-Span Post.pdf
Kamel Farid
 
Jacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia - Excels In Optimizing Software ApplicationsJacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia
 
Automatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and BeyondAutomatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and Beyond
NU_I_TODALAB
 
introduction technology technology tec.pptx
introduction technology technology tec.pptxintroduction technology technology tec.pptx
introduction technology technology tec.pptx
Iftikhar70
 
Agents chapter of Artificial intelligence
Agents chapter of Artificial intelligenceAgents chapter of Artificial intelligence
Agents chapter of Artificial intelligence
DebdeepMukherjee9
 
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdfLittle Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
gori42199
 
Slide share PPT of NOx control technologies.pptx
Slide share PPT of  NOx control technologies.pptxSlide share PPT of  NOx control technologies.pptx
Slide share PPT of NOx control technologies.pptx
vvsasane
 
Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...
Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...
Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...
AI Publications
 
Personal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.pptPersonal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.ppt
ganjangbegu579
 
Evonik Overview Visiomer Specialty Methacrylates.pdf
Evonik Overview Visiomer Specialty Methacrylates.pdfEvonik Overview Visiomer Specialty Methacrylates.pdf
Evonik Overview Visiomer Specialty Methacrylates.pdf
szhang13
 
DED KOMINFO detail engginering design gedung
DED KOMINFO detail engginering design gedungDED KOMINFO detail engginering design gedung
DED KOMINFO detail engginering design gedung
nabilarizqifadhilah1
 
Machine foundation notes for civil engineering students
Machine foundation notes for civil engineering studentsMachine foundation notes for civil engineering students
Machine foundation notes for civil engineering students
DYPCET
 
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
PawachMetharattanara
 
ATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ATAL 6 Days Online FDP Scheme Document 2025-26.pdfATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ssuserda39791
 
twin tower attack 2001 new york city
twin  tower  attack  2001 new  york citytwin  tower  attack  2001 new  york city
twin tower attack 2001 new york city
harishreemavs
 
2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt
rakshaiya16
 
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjjseninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
AjijahamadKhaji
 
Design of Variable Depth Single-Span Post.pdf
Design of Variable Depth Single-Span Post.pdfDesign of Variable Depth Single-Span Post.pdf
Design of Variable Depth Single-Span Post.pdf
Kamel Farid
 
Jacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia - Excels In Optimizing Software ApplicationsJacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia
 
Automatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and BeyondAutomatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and Beyond
NU_I_TODALAB
 

C Programming Language Step by Step Part 5

  • 1. With : Rumman Ansari
  • 2. Operators Precedence in C Category Operator Associativity Postfix () [] -> . ++ - - Left to right Unary + - ! ~ ++ - - (type)* & sizeof Right to left Multiplicative * / % Left to right Additive + - Left to right Shift << >> Left to right Relational < <= > >= Left to right Equality == != Left to right Bitwise AND & Left to right Bitwise XOR ^ Left to right Bitwise OR | Left to right Logical AND && Left to right Logical OR || Left to right Conditional ?: Right to left Assignment = += -= *= /= %=>>= <<= &= ^= |= Right to left Comma , Left to right
  • 3. #include<stdio.h> void main() { int x; x=-3+4*5-6; printf("%d n",x); x=3+(4%5)-6; printf("%d n",x); x=-3*4%-6/5; printf("%d n",x); x=(7+6)%5/2; printf("%d n",x); } 11 1 0 1 Program Output
  • 4. #include<stdio.h> void main() { int x=2,y,z; x*=3+2; printf("%d n",x); x*=y=z=4; printf("%d n",x); x=y==z; printf("%d n",x); x==(y=z); printf("%d n",x); } 10 40 1 1 Program Output
  • 5. #include<stdio.h> void main() { int x,y,z; x=2; y=1; z=9; x= x&&y||z; printf("%d n",x); printf("%d n",x||!y&&z); x=y=1; z=x++ -1; printf("%d n",x); printf("%d n",z); z+=-x ++ + ++y ; printf("%d n",x); printf("%d n",z); } Program Output 1 1 2 0 3 0
  • 6. Decision Making Statement Description if statement An if statement consists of a boolean expression followed by one or more statements. if...else statement An if statement can be followed by an optional else statement, which executes when the boolean expression is false. nested if statements You can use one if or else if statement inside another if orelse if statement(s). switch statement A switch statement allows a variable to be tested for equality against a list of values. nested switch statements You can use one switch statement inside another switchstatement(s).
  • 7. if #include <stdio.h> int main () { /* local variable definition */ int a = 10; /* check the boolean condition using if statement */ if( a < 20 ) { /* if condition is true then print the following */ printf("a is less than 20n" ); } printf("value of a is : %dn", a); return 0; } Flow Diagram: 1
  • 8. if...else statement Syntax: if(boolean_expression) { /* statement(s) will execute if the boolean expression is true */ } else { /* statement(s) will execute if the boolean expression is false */ } Flow Diagram: 2
  • 9. #include <stdio.h> int main () { /* local variable definition */ int a = 100; /* check the boolean condition */ if( a < 20 ) { /* if condition is true then print the following */ printf("a is less than 20n" ); } else { /* if condition is false then print the following */ printf("a is not less than 20n" ); } printf("value of a is : %dn", a); return 0; }
  • 10. if...else if...else Statement Syntax: if(boolean_expression 1) { /* Executes when the boolean expression 1 is true */ } else if( boolean_expression 2) { /* Executes when the boolean expression 2 is true */ } else if( boolean_expression 3) { /* Executes when the boolean expression 3 is true */ } else { /* executes when the none of the above condition is true */ } 3
  • 11. Example #include <stdio.h> int main () { /* local variable definition */ int a = 100; /* check the boolean condition */ if( a == 10 ) { /* if condition is true then print the following */ printf("Value of a is 10n" ); } else if( a == 20 ) { /* if else if condition is true */ printf("Value of a is 20n" ); } else if( a == 30 ) { /* if else if condition is true */ printf("Value of a is 30n" ); } else { /* if none of the conditions is true */ printf("None of the values is matchingn" ); } printf("Exact value of a is: %dn", a ); return 0; }
  • 12. nested if statements4 Syntax: if( boolean_expression 1) { /* Executes when the boolean expression 1 is true */ if(boolean_expression 2) { /* Executes when the boolean expression 2 is true */ } }
  • 13. Example #include <stdio.h> int main () { /* local variable definition */ int a = 100; int b = 200; /* check the boolean condition */ if( a == 100 ) { /* if condition is true then check the following */ if( b == 200 ) { /* if condition is true then print the following */ printf("Value of a is 100 and b is 200n" ); } } printf("Exact value of a is : %dn", a ); printf("Exact value of b is : %dn", b ); return 0; }
  • 14. switch statement Syntax: switch(expression){ case constant-expression : statement(s); break; /* optional */ case constant-expression : statement(s); break; /* optional */ /* you can have any number of case statements */ default : /* Optional */ statement(s); } switch ( integer expression ) { case constant 1 : do this ; case constant 2 : do this ; case constant 3 : do this ; default : do this ; } 5
  • 16. Example #include <stdio.h> int main () { /* local variable definition */ char grade = 'B'; switch(grade) { case 'A' : printf("Excellent!n" ); break; case 'B' : case 'C' : printf("Well donen" ); break; case 'D' : printf("You passedn" ); break; case 'F' : printf("Better try againn" ); break; default : printf("Invalid graden" ); } printf("Your grade is %cn", grade ); return 0; }
  • 17. nested switch statements Syntax: switch(ch1) { case 'A': printf("This A is part of outer switch" ); switch(ch2) { case 'A': printf("This A is part of inner switch" ); break; case 'B': /* case code */ } break; case 'B': /* case code */ } 6
  • 18. Example #include <stdio.h> int main () { /* local variable definition */ int a = 100; int b = 200; switch(a) { case 100: printf("This is part of outer switchn", a ); switch(b) { case 200: printf("This is part of inner switchn", a ); } } printf("Exact value of a is : %dn", a ); printf("Exact value of b is : %dn", b ); return 0; }
  翻译: