SlideShare a Scribd company logo
Presentation:- Functions
BY:
Arpit Modh (16BCH035)
B.Tech Chemical
Nirma University,
Ahmedabad.
Modular approach in C Programming
1. What actually the modular programming is..?
2. Types of Functions in C programming
3. Block building concept and its advantages
4. Function Definition/Call/Declaration
5. How do we define/Call and Declare the user define functions.
6. Actual and Formal Parameters in function
7. Different ways to use C functions
Why Function in C Programming
(Example to find PRIME number)
void main()
{
int n, i, flag=0;
printf("Enter a positive integer: ");
scanf("%d",&n);
for(i=2; i <= n/2; ++i)
{
if(n%i == 0)
{
flag = 1;
}
}
if (flag == 1)
printf("%d is not a prime number.", n);
else
printf("%d is a prime number.", n);
}
void main()
{
int n, i, flag=0;
void main()
{
int n, i, flag=0;
Why Function in C Programming
printf("Enter a positive integer: ");
scanf("%d",&n);
for(i=2; i <= n/2; ++i)
{
if(n%i == 0)
{
flag = 1;
}
}
if (flag == 1)
printf("%d is not a prime number.", n);
else
printf("%d is a prime number.", n);
}
read_number();
find_Prime();
Print_Result();
}
5
PART-I
1: Block Building Concept:
• Development philosophy is based on Modular approach
• Same operation is performed on different input data
• Easy to understand
• Easy to Debug
void main()
{
int n, i, flag=0;
read_number();
find_Prime();
Print_Result();
}
6
PART-I
2: Function Definition/Call/Declaration:
7
PART-I
2: Function Definition/Call/Declaration:
8
PART-I
3: Function Parameters (Actual and Formal)
9
PART-I
4: Different ways to use function
10
PART-I
4: Different ways to use function
Prof Kamal K Mehta Associate Professor CSE Institute of
Technology NIRMA University
24-12-2016 11
PART-I
4: Different ways to use function
12
PART-I
4: Different ways to use function
13
PART-I
4: Different ways to use function
void main()
{
int n, i, flag=0;
printf("Enter a positive integer: ");
scanf("%d",&n);
for(i=2; i <= n/2; ++i)
{
if(n%i == 0)
{
flag = 1;
}
}
if (flag == 1)
printf("%d is not a prime number.", n);
else
printf("%d is a prime number.", n);
}
C program to find a number is prime or not without using user defined function
#include <stdio.h>
void checkPrimeNumber();
int main()
{
checkPrimeNumber();
return 0;
}
void checkPrimeNumber()
{
int n, i, flag=0;
printf("Enter a positive integer: ");
scanf("%d",&n);
for(i=2; i <= n/2; ++i)
{
if(n%i == 0)
{
flag = 1;
}
}
if (flag == 1)
printf("%d is not a prime number.", n);
else
printf("%d is a prime number.", n);
}
Case 1: NO argument NO return value
Entire logic is a part of function
#include <stdio.h>
int getInteger();
int main()
{
int n, i, flag = 0;
// no argument is passed to the function // the value returned from the function is assigned to n
n = getInteger();
for(i=2; i<=n/2; ++i)
{
if(n%i==0)
{
flag = 1;
break;
}
}
if (flag == 1)
printf("%d is not a prime number.", n);
else
printf("%d is a prime number.", n);
return 0;
} // getInteger() function returns integer entered by the user
int getInteger()
{
int n;
printf("Enter a positive integer: ");
scanf("%d",&n);
return n;
}
Case 2: NO argument with Return value
Function will read only input number
#include <stdio.h>
void checkPrimeAndDisplay(int n);
int main()
{
int n;
printf("Enter a positive integer: ");
scanf("%d",&n);
checkPrimeAndDisplay(n);
return 0;
}
void checkPrimeAndDisplay(int n)
{
int i,
flag = 0;
for(i=2; i <= n/2; ++i)
{
if(n%i == 0)
{
flag = 1;
break;
}
}
if(flag == 1)
printf("%d is not a prime number.",n);
else
printf("%d is a prime number.", n);
}
Case 3: Argument without Return value
Function will receive input data from main () and perform prime checking
#include <stdio.h>
int checkPrimeNumber(int n);
int main()
{
int n, flag;
printf("Enter a positive integer: ");
scanf("%d",&n);
flag = checkPrimeNumber(n);
if(flag==1)
printf("%d is not a prime number",n);
else
printf("%d is a prime number",n);
return 0;
}
int checkPrimeNumber(int n)
{
int i;
for(i=2; i <= n/2; ++i)
{
if(n%i == 0)
return 1;
}
return 0;
}
Case 4: With Argument as well as Return value
Function will take input from main () and return the result to main ()
Functions

More Related Content

What's hot

C language operator
C language operatorC language operator
C language operator
cprogram
 
Plsql programs
Plsql programsPlsql programs
Simple c program
Simple c programSimple c program
Simple c program
Ravi Singh
 
88 c-programs
88 c-programs88 c-programs
88 c-programs
Leandro Schenone
 
Lab 1
Lab 1Lab 1
Factorial
FactorialFactorial
CP Handout#8
CP Handout#8CP Handout#8
CP Handout#8
trupti1976
 
C Language Programs
C Language Programs C Language Programs
C Language Programs
Mansi Tyagi
 
CP Handout#2
CP Handout#2CP Handout#2
CP Handout#2
trupti1976
 
7. input and output functions
7. input and output functions7. input and output functions
7. input and output functions
Way2itech
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
Mainak Sasmal
 
comp1
comp1comp1
comp1
franzneri
 
C lab-programs
C lab-programsC lab-programs
C lab-programs
Tony Kurishingal
 
Dam31303 dti2143 lab sheet 7
Dam31303 dti2143 lab sheet 7Dam31303 dti2143 lab sheet 7
Dam31303 dti2143 lab sheet 7
alish sha
 
Qust & ans inc
Qust & ans incQust & ans inc
Qust & ans inc
nayakq
 
C programming pointer
C  programming pointerC  programming pointer
C programming pointer
argusacademy
 
comp2
comp2comp2
comp2
franzneri
 
Hello world! Intro to C++
Hello world! Intro to C++Hello world! Intro to C++
Hello world! Intro to C++
DSCIGDTUW
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
Rahul Pandit
 
Lect08 exercises
Lect08 exercisesLect08 exercises
Lect08 exercises
AKalaji
 

What's hot (20)

C language operator
C language operatorC language operator
C language operator
 
Plsql programs
Plsql programsPlsql programs
Plsql programs
 
Simple c program
Simple c programSimple c program
Simple c program
 
88 c-programs
88 c-programs88 c-programs
88 c-programs
 
Lab 1
Lab 1Lab 1
Lab 1
 
Factorial
FactorialFactorial
Factorial
 
CP Handout#8
CP Handout#8CP Handout#8
CP Handout#8
 
C Language Programs
C Language Programs C Language Programs
C Language Programs
 
CP Handout#2
CP Handout#2CP Handout#2
CP Handout#2
 
7. input and output functions
7. input and output functions7. input and output functions
7. input and output functions
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
 
comp1
comp1comp1
comp1
 
C lab-programs
C lab-programsC lab-programs
C lab-programs
 
Dam31303 dti2143 lab sheet 7
Dam31303 dti2143 lab sheet 7Dam31303 dti2143 lab sheet 7
Dam31303 dti2143 lab sheet 7
 
Qust & ans inc
Qust & ans incQust & ans inc
Qust & ans inc
 
C programming pointer
C  programming pointerC  programming pointer
C programming pointer
 
comp2
comp2comp2
comp2
 
Hello world! Intro to C++
Hello world! Intro to C++Hello world! Intro to C++
Hello world! Intro to C++
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
 
Lect08 exercises
Lect08 exercisesLect08 exercises
Lect08 exercises
 

Viewers also liked

engage profile-print
engage profile-printengage profile-print
engage profile-print
Saif Al Tohamy
 
Criterii evaluare revista publicatie
Criterii evaluare revista publicatieCriterii evaluare revista publicatie
Criterii evaluare revista publicatie
Andrici Cezar
 
Our school
Our schoolOur school
Presidencia de Rivadavia, Guerra contra Brasil
Presidencia de Rivadavia, Guerra contra BrasilPresidencia de Rivadavia, Guerra contra Brasil
Presidencia de Rivadavia, Guerra contra Brasil
Martin Alberto Belaustegui
 
Junta Grande, 1er y 2do Triunvirato, Directorio, Batalla de Cepeda
Junta Grande, 1er y 2do Triunvirato, Directorio, Batalla de CepedaJunta Grande, 1er y 2do Triunvirato, Directorio, Batalla de Cepeda
Junta Grande, 1er y 2do Triunvirato, Directorio, Batalla de Cepeda
Martin Alberto Belaustegui
 
Arnaud giroux curriculum vitae, resume 2015
Arnaud giroux curriculum vitae, resume 2015Arnaud giroux curriculum vitae, resume 2015
Arnaud giroux curriculum vitae, resume 2015
Arnaud Giroux
 
Catálogo 7 de Oriflame España
Catálogo 7 de Oriflame EspañaCatálogo 7 de Oriflame España
Catálogo 7 de Oriflame España
Anika Díaz
 
Katalog oriflame september 2010
Katalog oriflame september 2010Katalog oriflame september 2010
Katalog oriflame september 2010
Liena Aifen
 
OData External Data Integration Strategies for SaaS
OData External Data Integration Strategies for SaaSOData External Data Integration Strategies for SaaS
OData External Data Integration Strategies for SaaS
Sumit Sarkar
 
Salesforce External Objects for Big Data
Salesforce External Objects for Big DataSalesforce External Objects for Big Data
Salesforce External Objects for Big Data
Sumit Sarkar
 
Planul unitatii de invatare
Planul unitatii de invatarePlanul unitatii de invatare
Planul unitatii de invatare
Andrici Cezar
 
Marcel Chiranov - Cum pot contribui bibliotecile la realizarea obiectivelor g...
Marcel Chiranov - Cum pot contribui bibliotecile la realizarea obiectivelor g...Marcel Chiranov - Cum pot contribui bibliotecile la realizarea obiectivelor g...
Marcel Chiranov - Cum pot contribui bibliotecile la realizarea obiectivelor g...
Biblioteca Națională a Republicii Moldova
 
Aurelia Spătaru - Cum putem transforma Moldova într-un loc mai bun până în 2030
Aurelia Spătaru - Cum putem transforma Moldova într-un loc mai bun până în 2030Aurelia Spătaru - Cum putem transforma Moldova într-un loc mai bun până în 2030
Aurelia Spătaru - Cum putem transforma Moldova într-un loc mai bun până în 2030
Biblioteca Națională a Republicii Moldova
 
1000 deintrebarisiraspunsuridespreviataduhovniceasca
1000 deintrebarisiraspunsuridespreviataduhovniceasca1000 deintrebarisiraspunsuridespreviataduhovniceasca
1000 deintrebarisiraspunsuridespreviataduhovniceasca
Elly Elly
 
Invtturilealesuluisievangheliaesenianaapcii 161125132558
Invtturilealesuluisievangheliaesenianaapcii 161125132558Invtturilealesuluisievangheliaesenianaapcii 161125132558
Invtturilealesuluisievangheliaesenianaapcii 161125132558
Costel Bucur
 
Judy Astley- Vicii agreabile
Judy Astley- Vicii agreabileJudy Astley- Vicii agreabile
Judy Astley- Vicii agreabile
Alina Ioana
 

Viewers also liked (16)

engage profile-print
engage profile-printengage profile-print
engage profile-print
 
Criterii evaluare revista publicatie
Criterii evaluare revista publicatieCriterii evaluare revista publicatie
Criterii evaluare revista publicatie
 
Our school
Our schoolOur school
Our school
 
Presidencia de Rivadavia, Guerra contra Brasil
Presidencia de Rivadavia, Guerra contra BrasilPresidencia de Rivadavia, Guerra contra Brasil
Presidencia de Rivadavia, Guerra contra Brasil
 
Junta Grande, 1er y 2do Triunvirato, Directorio, Batalla de Cepeda
Junta Grande, 1er y 2do Triunvirato, Directorio, Batalla de CepedaJunta Grande, 1er y 2do Triunvirato, Directorio, Batalla de Cepeda
Junta Grande, 1er y 2do Triunvirato, Directorio, Batalla de Cepeda
 
Arnaud giroux curriculum vitae, resume 2015
Arnaud giroux curriculum vitae, resume 2015Arnaud giroux curriculum vitae, resume 2015
Arnaud giroux curriculum vitae, resume 2015
 
Catálogo 7 de Oriflame España
Catálogo 7 de Oriflame EspañaCatálogo 7 de Oriflame España
Catálogo 7 de Oriflame España
 
Katalog oriflame september 2010
Katalog oriflame september 2010Katalog oriflame september 2010
Katalog oriflame september 2010
 
OData External Data Integration Strategies for SaaS
OData External Data Integration Strategies for SaaSOData External Data Integration Strategies for SaaS
OData External Data Integration Strategies for SaaS
 
Salesforce External Objects for Big Data
Salesforce External Objects for Big DataSalesforce External Objects for Big Data
Salesforce External Objects for Big Data
 
Planul unitatii de invatare
Planul unitatii de invatarePlanul unitatii de invatare
Planul unitatii de invatare
 
Marcel Chiranov - Cum pot contribui bibliotecile la realizarea obiectivelor g...
Marcel Chiranov - Cum pot contribui bibliotecile la realizarea obiectivelor g...Marcel Chiranov - Cum pot contribui bibliotecile la realizarea obiectivelor g...
Marcel Chiranov - Cum pot contribui bibliotecile la realizarea obiectivelor g...
 
Aurelia Spătaru - Cum putem transforma Moldova într-un loc mai bun până în 2030
Aurelia Spătaru - Cum putem transforma Moldova într-un loc mai bun până în 2030Aurelia Spătaru - Cum putem transforma Moldova într-un loc mai bun până în 2030
Aurelia Spătaru - Cum putem transforma Moldova într-un loc mai bun până în 2030
 
1000 deintrebarisiraspunsuridespreviataduhovniceasca
1000 deintrebarisiraspunsuridespreviataduhovniceasca1000 deintrebarisiraspunsuridespreviataduhovniceasca
1000 deintrebarisiraspunsuridespreviataduhovniceasca
 
Invtturilealesuluisievangheliaesenianaapcii 161125132558
Invtturilealesuluisievangheliaesenianaapcii 161125132558Invtturilealesuluisievangheliaesenianaapcii 161125132558
Invtturilealesuluisievangheliaesenianaapcii 161125132558
 
Judy Astley- Vicii agreabile
Judy Astley- Vicii agreabileJudy Astley- Vicii agreabile
Judy Astley- Vicii agreabile
 

Similar to Functions

C++ lab assignment
C++ lab assignmentC++ lab assignment
C++ lab assignment
Saket Pathak
 
C lab programs
C lab programsC lab programs
C lab programs
Dr. Prashant Vats
 
C lab programs
C lab programsC lab programs
C lab programs
Dr. Prashant Vats
 
Lab. Programs in C
Lab. Programs in CLab. Programs in C
Lab. Programs in C
Saket Pathak
 
Data struture lab
Data struture labData struture lab
Data struture lab
krishnamurthy Murthy.Tt
 
Compiler Construction | Lecture 2 | Declarative Syntax Definition
Compiler Construction | Lecture 2 | Declarative Syntax DefinitionCompiler Construction | Lecture 2 | Declarative Syntax Definition
Compiler Construction | Lecture 2 | Declarative Syntax Definition
Eelco Visser
 
C Programming
C ProgrammingC Programming
C Programming
Sumant Diwakar
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
Mainak Sasmal
 
operators.ppt
operators.pptoperators.ppt
operators.ppt
gamingwithfaulty
 
Fundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan KumariFundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan Kumari
THE NORTHCAP UNIVERSITY
 
Itp practical file_1-year
Itp practical file_1-yearItp practical file_1-year
Itp practical file_1-year
AMIT SINGH
 
CS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionCS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definition
Eelco Visser
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of c
Tushar B Kute
 
C
CC
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
Azhar Javed
 
Zoro123456789123456789123456789123456789
Zoro123456789123456789123456789123456789Zoro123456789123456789123456789123456789
Zoro123456789123456789123456789123456789
Ghh
 
labb123456789123456789123456789123456789
labb123456789123456789123456789123456789labb123456789123456789123456789123456789
labb123456789123456789123456789123456789
Ghh
 
Hargun
HargunHargun
Technical quiz 5#.pptx
Technical quiz 5#.pptxTechnical quiz 5#.pptx
Technical quiz 5#.pptx
kamalPatelposhala
 
C PROGRAMS
C PROGRAMSC PROGRAMS

Similar to Functions (20)

C++ lab assignment
C++ lab assignmentC++ lab assignment
C++ lab assignment
 
C lab programs
C lab programsC lab programs
C lab programs
 
C lab programs
C lab programsC lab programs
C lab programs
 
Lab. Programs in C
Lab. Programs in CLab. Programs in C
Lab. Programs in C
 
Data struture lab
Data struture labData struture lab
Data struture lab
 
Compiler Construction | Lecture 2 | Declarative Syntax Definition
Compiler Construction | Lecture 2 | Declarative Syntax DefinitionCompiler Construction | Lecture 2 | Declarative Syntax Definition
Compiler Construction | Lecture 2 | Declarative Syntax Definition
 
C Programming
C ProgrammingC Programming
C Programming
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
 
operators.ppt
operators.pptoperators.ppt
operators.ppt
 
Fundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan KumariFundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan Kumari
 
Itp practical file_1-year
Itp practical file_1-yearItp practical file_1-year
Itp practical file_1-year
 
CS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionCS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definition
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of c
 
C
CC
C
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
 
Zoro123456789123456789123456789123456789
Zoro123456789123456789123456789123456789Zoro123456789123456789123456789123456789
Zoro123456789123456789123456789123456789
 
labb123456789123456789123456789123456789
labb123456789123456789123456789123456789labb123456789123456789123456789123456789
labb123456789123456789123456789123456789
 
Hargun
HargunHargun
Hargun
 
Technical quiz 5#.pptx
Technical quiz 5#.pptxTechnical quiz 5#.pptx
Technical quiz 5#.pptx
 
C PROGRAMS
C PROGRAMSC PROGRAMS
C PROGRAMS
 

More from Arpit Modh

Cryogenic grinding
Cryogenic grindingCryogenic grinding
Cryogenic grinding
Arpit Modh
 
Values
ValuesValues
Values
Arpit Modh
 
Personality
PersonalityPersonality
Personality
Arpit Modh
 
Motivation
MotivationMotivation
Motivation
Arpit Modh
 
Organizational change
Organizational changeOrganizational change
Organizational change
Arpit Modh
 
Intellectual property rights
Intellectual property rightsIntellectual property rights
Intellectual property rights
Arpit Modh
 
Green synthesis of gold nano particles
Green synthesis of gold nano particlesGreen synthesis of gold nano particles
Green synthesis of gold nano particles
Arpit Modh
 
Acetone
AcetoneAcetone
Acetone
Arpit Modh
 
Pulp industries
Pulp industriesPulp industries
Pulp industries
Arpit Modh
 
Spectroscopy
SpectroscopySpectroscopy
Spectroscopy
Arpit Modh
 
Wireless power transmission
Wireless power transmissionWireless power transmission
Wireless power transmission
Arpit Modh
 
The kansas city hyatt regency walkway collapse
The kansas city hyatt regency walkway collapseThe kansas city hyatt regency walkway collapse
The kansas city hyatt regency walkway collapse
Arpit Modh
 
Nuclear waste
Nuclear wasteNuclear waste
Nuclear waste
Arpit Modh
 
Maxima & Minima of Calculus
Maxima & Minima of CalculusMaxima & Minima of Calculus
Maxima & Minima of Calculus
Arpit Modh
 
Communication skills
Communication skillsCommunication skills
Communication skills
Arpit Modh
 
Antarctica
AntarcticaAntarctica
Antarctica
Arpit Modh
 
Boiler Introduction & Classification
Boiler Introduction & ClassificationBoiler Introduction & Classification
Boiler Introduction & Classification
Arpit Modh
 

More from Arpit Modh (17)

Cryogenic grinding
Cryogenic grindingCryogenic grinding
Cryogenic grinding
 
Values
ValuesValues
Values
 
Personality
PersonalityPersonality
Personality
 
Motivation
MotivationMotivation
Motivation
 
Organizational change
Organizational changeOrganizational change
Organizational change
 
Intellectual property rights
Intellectual property rightsIntellectual property rights
Intellectual property rights
 
Green synthesis of gold nano particles
Green synthesis of gold nano particlesGreen synthesis of gold nano particles
Green synthesis of gold nano particles
 
Acetone
AcetoneAcetone
Acetone
 
Pulp industries
Pulp industriesPulp industries
Pulp industries
 
Spectroscopy
SpectroscopySpectroscopy
Spectroscopy
 
Wireless power transmission
Wireless power transmissionWireless power transmission
Wireless power transmission
 
The kansas city hyatt regency walkway collapse
The kansas city hyatt regency walkway collapseThe kansas city hyatt regency walkway collapse
The kansas city hyatt regency walkway collapse
 
Nuclear waste
Nuclear wasteNuclear waste
Nuclear waste
 
Maxima & Minima of Calculus
Maxima & Minima of CalculusMaxima & Minima of Calculus
Maxima & Minima of Calculus
 
Communication skills
Communication skillsCommunication skills
Communication skills
 
Antarctica
AntarcticaAntarctica
Antarctica
 
Boiler Introduction & Classification
Boiler Introduction & ClassificationBoiler Introduction & Classification
Boiler Introduction & Classification
 

Recently uploaded

李易峰祝绪丹做爱视频流出【网芷:ht28.co】可爱学生妹>>>[网趾:ht28.co】]<<<
李易峰祝绪丹做爱视频流出【网芷:ht28.co】可爱学生妹>>>[网趾:ht28.co】]<<<李易峰祝绪丹做爱视频流出【网芷:ht28.co】可爱学生妹>>>[网趾:ht28.co】]<<<
李易峰祝绪丹做爱视频流出【网芷:ht28.co】可爱学生妹>>>[网趾:ht28.co】]<<<
amzhoxvzidbke
 
Online airline reservation system project report.pdf
Online airline reservation system project report.pdfOnline airline reservation system project report.pdf
Online airline reservation system project report.pdf
Kamal Acharya
 
How to Formulate A Good Research Question
How to Formulate A  Good Research QuestionHow to Formulate A  Good Research Question
How to Formulate A Good Research Question
rkpv2002
 
Online toll plaza booking system project report.doc.pdf
Online toll plaza booking system project report.doc.pdfOnline toll plaza booking system project report.doc.pdf
Online toll plaza booking system project report.doc.pdf
Kamal Acharya
 
Thermodynamics Digital Material basics subject
Thermodynamics Digital Material basics subjectThermodynamics Digital Material basics subject
Thermodynamics Digital Material basics subject
JigneshChhatbar1
 
ANATOMY OF SOA - Thomas Erl - Service Oriented Architecture
ANATOMY OF SOA - Thomas Erl - Service Oriented ArchitectureANATOMY OF SOA - Thomas Erl - Service Oriented Architecture
ANATOMY OF SOA - Thomas Erl - Service Oriented Architecture
Divya Rajasekar
 
Presentation slide on DESIGN AND FABRICATION OF MOBILE CONTROLLED DRAINAGE.pptx
Presentation slide on DESIGN AND FABRICATION OF MOBILE CONTROLLED DRAINAGE.pptxPresentation slide on DESIGN AND FABRICATION OF MOBILE CONTROLLED DRAINAGE.pptx
Presentation slide on DESIGN AND FABRICATION OF MOBILE CONTROLLED DRAINAGE.pptx
Er. Kushal Ghimire
 
Ludo system project report management .pdf
Ludo  system project report management .pdfLudo  system project report management .pdf
Ludo system project report management .pdf
Kamal Acharya
 
# Smart Parking Management System.pptx using IOT
# Smart Parking Management System.pptx using IOT# Smart Parking Management System.pptx using IOT
# Smart Parking Management System.pptx using IOT
Yesh20
 
Top EPC companies in India - Best EPC Contractor
Top EPC companies in India - Best EPC  ContractorTop EPC companies in India - Best EPC  Contractor
Top EPC companies in India - Best EPC Contractor
MangeshK6
 
杨洋李一桐做爱视频流出【网芷:ht28.co】国产国产午夜精华>>>[网趾:ht28.co】]<<<
杨洋李一桐做爱视频流出【网芷:ht28.co】国产国产午夜精华>>>[网趾:ht28.co】]<<<杨洋李一桐做爱视频流出【网芷:ht28.co】国产国产午夜精华>>>[网趾:ht28.co】]<<<
杨洋李一桐做爱视频流出【网芷:ht28.co】国产国产午夜精华>>>[网趾:ht28.co】]<<<
amzhoxvzidbke
 
Adv. Digital Signal Processing LAB MANUAL.pdf
Adv. Digital Signal Processing LAB MANUAL.pdfAdv. Digital Signal Processing LAB MANUAL.pdf
Adv. Digital Signal Processing LAB MANUAL.pdf
T.D. Shashikala
 
The Control of Relative Humidity & Moisture Content in The Air
The Control of Relative Humidity & Moisture Content in The AirThe Control of Relative Humidity & Moisture Content in The Air
The Control of Relative Humidity & Moisture Content in The Air
Ashraf Ismail
 
Concepts Basic/ Technical Electronic Material.pdf
Concepts Basic/ Technical Electronic Material.pdfConcepts Basic/ Technical Electronic Material.pdf
Concepts Basic/ Technical Electronic Material.pdf
OBD II
 
PPT_grt.pptx engineering criteria grt for accrediation
PPT_grt.pptx engineering criteria  grt for accrediationPPT_grt.pptx engineering criteria  grt for accrediation
PPT_grt.pptx engineering criteria grt for accrediation
SHALINIRAJAN20
 
SCADAmetrics Instrumentation for Sensus Water Meters - Core and Main Training...
SCADAmetrics Instrumentation for Sensus Water Meters - Core and Main Training...SCADAmetrics Instrumentation for Sensus Water Meters - Core and Main Training...
SCADAmetrics Instrumentation for Sensus Water Meters - Core and Main Training...
Jim Mimlitz, P.E.
 
FINE-TUNING OF SMALL/MEDIUM LLMS FOR BUSINESS QA ON STRUCTURED DATA
FINE-TUNING OF SMALL/MEDIUM LLMS FOR BUSINESS QA ON STRUCTURED DATAFINE-TUNING OF SMALL/MEDIUM LLMS FOR BUSINESS QA ON STRUCTURED DATA
FINE-TUNING OF SMALL/MEDIUM LLMS FOR BUSINESS QA ON STRUCTURED DATA
kevig
 
Software Engineering and Project Management - Activity Planning
Software Engineering and Project Management - Activity PlanningSoftware Engineering and Project Management - Activity Planning
Software Engineering and Project Management - Activity Planning
Prakhyath Rai
 
RECENT DEVELOPMENTS IN RING SPINNING.pptx
RECENT DEVELOPMENTS IN RING SPINNING.pptxRECENT DEVELOPMENTS IN RING SPINNING.pptx
RECENT DEVELOPMENTS IN RING SPINNING.pptx
peacesoul123
 
Disaster Management and Mitigation presentation
Disaster Management and Mitigation presentationDisaster Management and Mitigation presentation
Disaster Management and Mitigation presentation
RajaRamannaTarigoppu
 

Recently uploaded (20)

李易峰祝绪丹做爱视频流出【网芷:ht28.co】可爱学生妹>>>[网趾:ht28.co】]<<<
李易峰祝绪丹做爱视频流出【网芷:ht28.co】可爱学生妹>>>[网趾:ht28.co】]<<<李易峰祝绪丹做爱视频流出【网芷:ht28.co】可爱学生妹>>>[网趾:ht28.co】]<<<
李易峰祝绪丹做爱视频流出【网芷:ht28.co】可爱学生妹>>>[网趾:ht28.co】]<<<
 
Online airline reservation system project report.pdf
Online airline reservation system project report.pdfOnline airline reservation system project report.pdf
Online airline reservation system project report.pdf
 
How to Formulate A Good Research Question
How to Formulate A  Good Research QuestionHow to Formulate A  Good Research Question
How to Formulate A Good Research Question
 
Online toll plaza booking system project report.doc.pdf
Online toll plaza booking system project report.doc.pdfOnline toll plaza booking system project report.doc.pdf
Online toll plaza booking system project report.doc.pdf
 
Thermodynamics Digital Material basics subject
Thermodynamics Digital Material basics subjectThermodynamics Digital Material basics subject
Thermodynamics Digital Material basics subject
 
ANATOMY OF SOA - Thomas Erl - Service Oriented Architecture
ANATOMY OF SOA - Thomas Erl - Service Oriented ArchitectureANATOMY OF SOA - Thomas Erl - Service Oriented Architecture
ANATOMY OF SOA - Thomas Erl - Service Oriented Architecture
 
Presentation slide on DESIGN AND FABRICATION OF MOBILE CONTROLLED DRAINAGE.pptx
Presentation slide on DESIGN AND FABRICATION OF MOBILE CONTROLLED DRAINAGE.pptxPresentation slide on DESIGN AND FABRICATION OF MOBILE CONTROLLED DRAINAGE.pptx
Presentation slide on DESIGN AND FABRICATION OF MOBILE CONTROLLED DRAINAGE.pptx
 
Ludo system project report management .pdf
Ludo  system project report management .pdfLudo  system project report management .pdf
Ludo system project report management .pdf
 
# Smart Parking Management System.pptx using IOT
# Smart Parking Management System.pptx using IOT# Smart Parking Management System.pptx using IOT
# Smart Parking Management System.pptx using IOT
 
Top EPC companies in India - Best EPC Contractor
Top EPC companies in India - Best EPC  ContractorTop EPC companies in India - Best EPC  Contractor
Top EPC companies in India - Best EPC Contractor
 
杨洋李一桐做爱视频流出【网芷:ht28.co】国产国产午夜精华>>>[网趾:ht28.co】]<<<
杨洋李一桐做爱视频流出【网芷:ht28.co】国产国产午夜精华>>>[网趾:ht28.co】]<<<杨洋李一桐做爱视频流出【网芷:ht28.co】国产国产午夜精华>>>[网趾:ht28.co】]<<<
杨洋李一桐做爱视频流出【网芷:ht28.co】国产国产午夜精华>>>[网趾:ht28.co】]<<<
 
Adv. Digital Signal Processing LAB MANUAL.pdf
Adv. Digital Signal Processing LAB MANUAL.pdfAdv. Digital Signal Processing LAB MANUAL.pdf
Adv. Digital Signal Processing LAB MANUAL.pdf
 
The Control of Relative Humidity & Moisture Content in The Air
The Control of Relative Humidity & Moisture Content in The AirThe Control of Relative Humidity & Moisture Content in The Air
The Control of Relative Humidity & Moisture Content in The Air
 
Concepts Basic/ Technical Electronic Material.pdf
Concepts Basic/ Technical Electronic Material.pdfConcepts Basic/ Technical Electronic Material.pdf
Concepts Basic/ Technical Electronic Material.pdf
 
PPT_grt.pptx engineering criteria grt for accrediation
PPT_grt.pptx engineering criteria  grt for accrediationPPT_grt.pptx engineering criteria  grt for accrediation
PPT_grt.pptx engineering criteria grt for accrediation
 
SCADAmetrics Instrumentation for Sensus Water Meters - Core and Main Training...
SCADAmetrics Instrumentation for Sensus Water Meters - Core and Main Training...SCADAmetrics Instrumentation for Sensus Water Meters - Core and Main Training...
SCADAmetrics Instrumentation for Sensus Water Meters - Core and Main Training...
 
FINE-TUNING OF SMALL/MEDIUM LLMS FOR BUSINESS QA ON STRUCTURED DATA
FINE-TUNING OF SMALL/MEDIUM LLMS FOR BUSINESS QA ON STRUCTURED DATAFINE-TUNING OF SMALL/MEDIUM LLMS FOR BUSINESS QA ON STRUCTURED DATA
FINE-TUNING OF SMALL/MEDIUM LLMS FOR BUSINESS QA ON STRUCTURED DATA
 
Software Engineering and Project Management - Activity Planning
Software Engineering and Project Management - Activity PlanningSoftware Engineering and Project Management - Activity Planning
Software Engineering and Project Management - Activity Planning
 
RECENT DEVELOPMENTS IN RING SPINNING.pptx
RECENT DEVELOPMENTS IN RING SPINNING.pptxRECENT DEVELOPMENTS IN RING SPINNING.pptx
RECENT DEVELOPMENTS IN RING SPINNING.pptx
 
Disaster Management and Mitigation presentation
Disaster Management and Mitigation presentationDisaster Management and Mitigation presentation
Disaster Management and Mitigation presentation
 

Functions

  • 1. Presentation:- Functions BY: Arpit Modh (16BCH035) B.Tech Chemical Nirma University, Ahmedabad.
  • 2. Modular approach in C Programming 1. What actually the modular programming is..? 2. Types of Functions in C programming 3. Block building concept and its advantages 4. Function Definition/Call/Declaration 5. How do we define/Call and Declare the user define functions. 6. Actual and Formal Parameters in function 7. Different ways to use C functions
  • 3. Why Function in C Programming (Example to find PRIME number) void main() { int n, i, flag=0; printf("Enter a positive integer: "); scanf("%d",&n); for(i=2; i <= n/2; ++i) { if(n%i == 0) { flag = 1; } } if (flag == 1) printf("%d is not a prime number.", n); else printf("%d is a prime number.", n); }
  • 4. void main() { int n, i, flag=0; void main() { int n, i, flag=0; Why Function in C Programming printf("Enter a positive integer: "); scanf("%d",&n); for(i=2; i <= n/2; ++i) { if(n%i == 0) { flag = 1; } } if (flag == 1) printf("%d is not a prime number.", n); else printf("%d is a prime number.", n); } read_number(); find_Prime(); Print_Result(); }
  • 5. 5 PART-I 1: Block Building Concept: • Development philosophy is based on Modular approach • Same operation is performed on different input data • Easy to understand • Easy to Debug void main() { int n, i, flag=0; read_number(); find_Prime(); Print_Result(); }
  • 8. 8 PART-I 3: Function Parameters (Actual and Formal)
  • 9. 9 PART-I 4: Different ways to use function
  • 10. 10 PART-I 4: Different ways to use function
  • 11. Prof Kamal K Mehta Associate Professor CSE Institute of Technology NIRMA University 24-12-2016 11 PART-I 4: Different ways to use function
  • 12. 12 PART-I 4: Different ways to use function
  • 13. 13 PART-I 4: Different ways to use function
  • 14. void main() { int n, i, flag=0; printf("Enter a positive integer: "); scanf("%d",&n); for(i=2; i <= n/2; ++i) { if(n%i == 0) { flag = 1; } } if (flag == 1) printf("%d is not a prime number.", n); else printf("%d is a prime number.", n); } C program to find a number is prime or not without using user defined function
  • 15. #include <stdio.h> void checkPrimeNumber(); int main() { checkPrimeNumber(); return 0; } void checkPrimeNumber() { int n, i, flag=0; printf("Enter a positive integer: "); scanf("%d",&n); for(i=2; i <= n/2; ++i) { if(n%i == 0) { flag = 1; } } if (flag == 1) printf("%d is not a prime number.", n); else printf("%d is a prime number.", n); } Case 1: NO argument NO return value Entire logic is a part of function
  • 16. #include <stdio.h> int getInteger(); int main() { int n, i, flag = 0; // no argument is passed to the function // the value returned from the function is assigned to n n = getInteger(); for(i=2; i<=n/2; ++i) { if(n%i==0) { flag = 1; break; } } if (flag == 1) printf("%d is not a prime number.", n); else printf("%d is a prime number.", n); return 0; } // getInteger() function returns integer entered by the user int getInteger() { int n; printf("Enter a positive integer: "); scanf("%d",&n); return n; } Case 2: NO argument with Return value Function will read only input number
  • 17. #include <stdio.h> void checkPrimeAndDisplay(int n); int main() { int n; printf("Enter a positive integer: "); scanf("%d",&n); checkPrimeAndDisplay(n); return 0; } void checkPrimeAndDisplay(int n) { int i, flag = 0; for(i=2; i <= n/2; ++i) { if(n%i == 0) { flag = 1; break; } } if(flag == 1) printf("%d is not a prime number.",n); else printf("%d is a prime number.", n); } Case 3: Argument without Return value Function will receive input data from main () and perform prime checking
  • 18. #include <stdio.h> int checkPrimeNumber(int n); int main() { int n, flag; printf("Enter a positive integer: "); scanf("%d",&n); flag = checkPrimeNumber(n); if(flag==1) printf("%d is not a prime number",n); else printf("%d is a prime number",n); return 0; } int checkPrimeNumber(int n) { int i; for(i=2; i <= n/2; ++i) { if(n%i == 0) return 1; } return 0; } Case 4: With Argument as well as Return value Function will take input from main () and return the result to main ()