SlideShare uma empresa Scribd logo
1 de 18
Functions in C Language
main()
main()
main()
main()
main()x
y
x is actual argument
y is formal argument
y
x 5
5
voidintfloat
#include<stdio.h>
#include<conio.h>
int maxint(int,int); // prototype of the function
int main()
{
int x, y;
int max;
clrscr();
printf(“Enter 2 numbersn”);
scanf(“%d%d”,&x,&qy);
max = maxint(x,y); // function call
printf(“Largest number is %dn”,max);
getch();
}
int maxint(int p, int q)
{
if(p>q)
return p;
else
return q;
}
#include<stdio.h>
#include<conio.h>
int maxint(int,int); // prototype of the function
int main()
{
int x, y;
int max;
clrscr();
printf(“Enter 2 numbersn”);
scanf(“%d%d”,&x,&q);
int maxint(int x, int x)
{
if(x>y)
return x;
else
return y;
}
getch();
}
One function block inside other
function block
#include<stdio.h>
#include<conio.h>
int maxint(int,int); // prototype of the function
int main()
{
int x, y;
int max;
clrscr();
printf(“Enter 2 numbersn”);
scanf(“%d%d”,&x,&qy);
max = maxint(x,y); // function call
printf(“Largest number is %dn”,max);
getch();
}
int maxint(int p, int q)
{
if(p>q)
return p;
else
return q;
}
#include<stdio.h>
#include<conio.h>
int maxint(int,int); // prototype of the function
int main()
{
int x, y;
int max;
clrscr();
printf(“Enter 2 numbersn”);
scanf(“%d%d”,&x,&qy);
max = maxint(x,y); // function call
printf(“Largest number is %dn”,max);
getch();
}
int maxint(int p, int q)
{
if(p>q)
return (p);
else
return q;
}
Factorial value
n! = n * n-1 * n-2 * n-3 * n-4……..
5! = 5 * 4 * 3 * 2 * 1
5! = 120
#include<stdio.h>
#include<conio.h>
void main()
{
int number;
int fact;
clrscr();
printf(“Enter Numbert”);
scanf(“%d”,&number);
fact = factorial(number);
printf(“%d! = %dn”,number,fact);
getch();
}
int factorial(int x)
{
int i;
int f = 1;
for(i=x; i >= 1; i--)
{
f = f * i;
}
return f;
}
Return type Formal argument
5! = 5 * 4 * 3 * 2 * 1
5 1
x

Mais conteúdo relacionado

Mais procurados

Function in c program
Function in c programFunction in c program
Function in c programumesh patil
 
Presentation on function
Presentation on functionPresentation on function
Presentation on functionAbu Zaman
 
Types of function call
Types of function callTypes of function call
Types of function callArijitDhali
 
Function in c language(defination and declaration)
Function in c language(defination and declaration)Function in c language(defination and declaration)
Function in c language(defination and declaration)VC Infotech
 
parameter passing in c#
parameter passing in c#parameter passing in c#
parameter passing in c#khush_boo31
 
C Prog - Functions
C Prog - FunctionsC Prog - Functions
C Prog - Functionsvinay arora
 
functions in C and types
functions in C and typesfunctions in C and types
functions in C and typesmubashir farooq
 
Call by value or call by reference in C++
Call by value or call by reference in C++Call by value or call by reference in C++
Call by value or call by reference in C++Sachin Yadav
 
C++ Function
C++ FunctionC++ Function
C++ FunctionHajar
 
Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)Dharma Kshetri
 
Lecture#6 functions in c++
Lecture#6 functions in c++Lecture#6 functions in c++
Lecture#6 functions in c++NUST Stuff
 
Lecture#7 Call by value and reference in c++
Lecture#7 Call by value and reference in c++Lecture#7 Call by value and reference in c++
Lecture#7 Call by value and reference in c++NUST Stuff
 

Mais procurados (20)

Function in c
Function in cFunction in c
Function in c
 
Function lecture
Function lectureFunction lecture
Function lecture
 
Function in c program
Function in c programFunction in c program
Function in c program
 
Presentation on function
Presentation on functionPresentation on function
Presentation on function
 
Function
FunctionFunction
Function
 
Types of function call
Types of function callTypes of function call
Types of function call
 
Function in c language(defination and declaration)
Function in c language(defination and declaration)Function in c language(defination and declaration)
Function in c language(defination and declaration)
 
Functions
FunctionsFunctions
Functions
 
C function presentation
C function presentationC function presentation
C function presentation
 
parameter passing in c#
parameter passing in c#parameter passing in c#
parameter passing in c#
 
C and C++ functions
C and C++ functionsC and C++ functions
C and C++ functions
 
Functionincprogram
FunctionincprogramFunctionincprogram
Functionincprogram
 
C Prog - Functions
C Prog - FunctionsC Prog - Functions
C Prog - Functions
 
functions in C and types
functions in C and typesfunctions in C and types
functions in C and types
 
CHAPTER 6
CHAPTER 6CHAPTER 6
CHAPTER 6
 
Call by value or call by reference in C++
Call by value or call by reference in C++Call by value or call by reference in C++
Call by value or call by reference in C++
 
C++ Function
C++ FunctionC++ Function
C++ Function
 
Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)
 
Lecture#6 functions in c++
Lecture#6 functions in c++Lecture#6 functions in c++
Lecture#6 functions in c++
 
Lecture#7 Call by value and reference in c++
Lecture#7 Call by value and reference in c++Lecture#7 Call by value and reference in c++
Lecture#7 Call by value and reference in c++
 

Destaque

Intro to cprogramming
Intro to cprogrammingIntro to cprogramming
Intro to cprogrammingskashwin98
 
Introduction to go language programming
Introduction to go language programmingIntroduction to go language programming
Introduction to go language programmingMahmoud Masih Tehrani
 
GO programming language
GO programming languageGO programming language
GO programming languagetung vu
 
C standard library functions
C standard library functionsC standard library functions
C standard library functionsVaishnavee Sharma
 
Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming languageVasavi College of Engg
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programmingavikdhupar
 

Destaque (7)

Intro to cprogramming
Intro to cprogrammingIntro to cprogramming
Intro to cprogramming
 
Introduction to go language programming
Introduction to go language programmingIntroduction to go language programming
Introduction to go language programming
 
GO programming language
GO programming languageGO programming language
GO programming language
 
C standard library functions
C standard library functionsC standard library functions
C standard library functions
 
functions in C
functions in Cfunctions in C
functions in C
 
Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming language
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
 

Semelhante a Functions in c (20)

SaraPIC
SaraPICSaraPIC
SaraPIC
 
C basics
C basicsC basics
C basics
 
Cquestions
Cquestions Cquestions
Cquestions
 
C questions
C questionsC questions
C questions
 
6. function
6. function6. function
6. function
 
String Manipulation Function and Header File Functions
String Manipulation Function and Header File FunctionsString Manipulation Function and Header File Functions
String Manipulation Function and Header File Functions
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
 
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
 
Functions
FunctionsFunctions
Functions
 
C Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossainC Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossain
 
7 functions
7  functions7  functions
7 functions
 
C Programming
C ProgrammingC Programming
C Programming
 
Common problems solving using c
Common problems solving using cCommon problems solving using c
Common problems solving using c
 
Functions
FunctionsFunctions
Functions
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 
Pnno
PnnoPnno
Pnno
 
Pointer basics
Pointer basicsPointer basics
Pointer basics
 
Function basics
Function basicsFunction basics
Function basics
 
C Prog - Pointers
C Prog - PointersC Prog - Pointers
C Prog - Pointers
 

Mais de Innovative

Addition of binary numbers
Addition of binary numbersAddition of binary numbers
Addition of binary numbersInnovative
 
Relational Operators in C Language
Relational Operators in C LanguageRelational Operators in C Language
Relational Operators in C LanguageInnovative
 
Break and continue statement in C
Break and continue statement in CBreak and continue statement in C
Break and continue statement in CInnovative
 
If control structure in c lnaguage
If control structure in c lnaguageIf control structure in c lnaguage
If control structure in c lnaguageInnovative
 
Pointers in C basics 01
Pointers in C basics 01Pointers in C basics 01
Pointers in C basics 01Innovative
 
Bitwise AND operator in c
Bitwise AND operator in cBitwise AND operator in c
Bitwise AND operator in cInnovative
 
Escape sequence in c part 1
Escape sequence in c   part 1Escape sequence in c   part 1
Escape sequence in c part 1Innovative
 

Mais de Innovative (7)

Addition of binary numbers
Addition of binary numbersAddition of binary numbers
Addition of binary numbers
 
Relational Operators in C Language
Relational Operators in C LanguageRelational Operators in C Language
Relational Operators in C Language
 
Break and continue statement in C
Break and continue statement in CBreak and continue statement in C
Break and continue statement in C
 
If control structure in c lnaguage
If control structure in c lnaguageIf control structure in c lnaguage
If control structure in c lnaguage
 
Pointers in C basics 01
Pointers in C basics 01Pointers in C basics 01
Pointers in C basics 01
 
Bitwise AND operator in c
Bitwise AND operator in cBitwise AND operator in c
Bitwise AND operator in c
 
Escape sequence in c part 1
Escape sequence in c   part 1Escape sequence in c   part 1
Escape sequence in c part 1
 

Último

Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 

Último (20)

Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 

Functions in c