SlideShare une entreprise Scribd logo
1  sur  4
C ProgrammingLanguage WorkingwithFunctions1
Agenda:
What is a Functions?
A function is a named, independent section of C code that performs a specific task and optionally returns a value
to the callingprogram
A function is named. Each function has a unique name. By usingthat name in another partof the program, you
can execute the statements contained in the function.This is known as callingthefunction. A function can be
called fromwithin another function.
A function is independent. A function can perform its task without interference from or interferingwith other
parts of the program.
A function performs a specific task. This is the easy partof the definition.A task is a discretejob that your
program must perform as partof its overall operation,such as sendinga lineof text to a printer, sortingan array
into numerical order,or calculatinga cuberoot.
function can return a value to the calling program. When your program callsa function,the statements it
contains areexecuted. If you want them to, these statements can pass information back to the callingprogram.
Benefits of the functions
program
Function Terminology
Function prototype: A function's prototype contains the name of the function,return type, a lis tof variables that
must be passed to it, and the type of variableitreturns, if any..
Function Definition: The function itself is called the function definition.The definition contains the code that will
be executed.
C ProgrammingLanguage WorkingwithFunctions2
Function header: The function header is atthe startof a function,and itgives the function's name. The header
also gives the function's return type and describes its arguments.Note that the function header is identical to the
function prototype (minus the semicolon).
Function Body: The statements written within function arecalled function body. Statements are enclosed in
braces.These statements are executed when the function is called.
Arguments: When a function is called,the program can send the function information in the form of one or more
arguments. An argument is programdata needed by the function to perform its task.Arguments are enclosed in
parentheses followingthe function's name.
Return statement: If the function return type is anythingother than void, a return statement should be included,
returning a valuematching the return type.
/* Demonstrates a simple function */
#include<stdio.h>
longcube(long x);
longinput, answer;
main()
{
printf("Enter an integer value: ");
scanf("%d", &input);
answer = cube(input); /*here input is actual argument.
/* Note: %ld is the conversion specifier for */
/* a long integer */
printf("nThe cube of %ld is %ld.n", input, answer);
return 0;
}
/* Function: cube() - Calculates thecubed valueof a variable*/
longcube(long x) /*here x is formal argument*/
{
longx_cubed;
x_cubed = x * x * x;
return x_cubed;
}
How does a Function Works
program.
C ProgrammingLanguage WorkingwithFunctions3
m of one or more arguments.
An argument is programdata needed by the function to perform its task.The statements in the function then
execute, performing whatever task each was designed to do.
sses back to the same location in the program that
called the function. Functions can send information back to the program in the form of a return value.
xecution passes
back to the placefrom which the function was called.A function can be called as many times as needed, and
functions can be called in any order.
#include<stdio.h>
void printline(char ch,intn);
int add(inta,intb,int c);
main()
{
int result;
printline('#',70);
result=add(10,3,4);
printf("n resultis %d",result);
getch();
return 0;
}
void printline(char ch,intn)
{
int i;
for(i=0;i<n;i++)
printf("%c",ch);
}
int add(inta,intb,int c)
{ C ProgrammingLanguage WorkingwithFunctions4
return a+b+c;
} /* Program to check the given value is vowel */
#include<stdio.h>
void main()
{
char ch;
printf("nEnter any character …');
ch=getch();
if(checkvowel(ch)==1)
printf("n It is a vowel");
else
printf("n try again");
}
int checkvowel(char ch)
{
if(ch=='a'||ch=='c'||ch=='i'||ch=='o'||ch=='u'||ch='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
return (1);
else
return (0);
}

Contenu connexe

Tendances (20)

User defined functions
User defined functionsUser defined functions
User defined functions
 
user defined function
user defined functionuser defined function
user defined function
 
User defined functions in C
User defined functions in CUser defined functions in C
User defined functions in C
 
Functionincprogram
FunctionincprogramFunctionincprogram
Functionincprogram
 
Functions
FunctionsFunctions
Functions
 
Function & Recursion
Function & RecursionFunction & Recursion
Function & Recursion
 
Function
FunctionFunction
Function
 
Pointers and call by value, reference, address in C
Pointers and call by value, reference, address in CPointers and call by value, reference, address in C
Pointers and call by value, reference, address in C
 
Function
FunctionFunction
Function
 
User Defined Functions
User Defined FunctionsUser Defined Functions
User Defined Functions
 
Function Parameters
Function ParametersFunction Parameters
Function Parameters
 
Functions
FunctionsFunctions
Functions
 
Scope of variables
Scope of variablesScope of variables
Scope of variables
 
Modular Programming in C
Modular Programming in CModular Programming in C
Modular Programming in C
 
Method parameters in c#
Method parameters in c#Method parameters in c#
Method parameters in c#
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
Function in c++
Function in c++Function in c++
Function in c++
 
Basic information of function in cpu
Basic information of function in cpuBasic information of function in cpu
Basic information of function in cpu
 
C language for Semester Exams for Engineers
C language for Semester Exams for Engineers C language for Semester Exams for Engineers
C language for Semester Exams for Engineers
 
Function
FunctionFunction
Function
 

En vedette

South Florida Real Estate 2017 Outlook Survey
South Florida Real Estate 2017 Outlook SurveySouth Florida Real Estate 2017 Outlook Survey
South Florida Real Estate 2017 Outlook Surveycutmytaxes
 
A non residents guide to buying property in florida
A non residents guide to buying property in  floridaA non residents guide to buying property in  florida
A non residents guide to buying property in floridaJames Lavigne
 
Make It Happen Homes Listing Presentation for North Texas Real Estate
Make It Happen Homes Listing Presentation for North Texas Real EstateMake It Happen Homes Listing Presentation for North Texas Real Estate
Make It Happen Homes Listing Presentation for North Texas Real EstateMary Lou Jaimes
 
Listing Presentation
Listing PresentationListing Presentation
Listing PresentationLenneaA
 
Realty Elite | Listing Presentation
Realty Elite  |  Listing PresentationRealty Elite  |  Listing Presentation
Realty Elite | Listing PresentationRealty Elite
 
Luxury Real Estate Listing Presentation
Luxury Real Estate Listing PresentationLuxury Real Estate Listing Presentation
Luxury Real Estate Listing PresentationGary Grimes
 
25 Real Estate Marketing Ideas The Pro's Use
25 Real Estate Marketing Ideas The Pro's Use25 Real Estate Marketing Ideas The Pro's Use
25 Real Estate Marketing Ideas The Pro's UseFit Small Business
 
Listing presentation Dawn Bahr
Listing presentation Dawn BahrListing presentation Dawn Bahr
Listing presentation Dawn BahrDawn Bahr
 
3 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 20173 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 2017Drift
 

En vedette (11)

South Florida Real Estate 2017 Outlook Survey
South Florida Real Estate 2017 Outlook SurveySouth Florida Real Estate 2017 Outlook Survey
South Florida Real Estate 2017 Outlook Survey
 
A non residents guide to buying property in florida
A non residents guide to buying property in  floridaA non residents guide to buying property in  florida
A non residents guide to buying property in florida
 
Make It Happen Homes Listing Presentation for North Texas Real Estate
Make It Happen Homes Listing Presentation for North Texas Real EstateMake It Happen Homes Listing Presentation for North Texas Real Estate
Make It Happen Homes Listing Presentation for North Texas Real Estate
 
La Jolla Agent Listing Presentation
La Jolla Agent Listing PresentationLa Jolla Agent Listing Presentation
La Jolla Agent Listing Presentation
 
Listing Presentation
Listing PresentationListing Presentation
Listing Presentation
 
Real Estate Listing Presentation
Real Estate Listing PresentationReal Estate Listing Presentation
Real Estate Listing Presentation
 
Realty Elite | Listing Presentation
Realty Elite  |  Listing PresentationRealty Elite  |  Listing Presentation
Realty Elite | Listing Presentation
 
Luxury Real Estate Listing Presentation
Luxury Real Estate Listing PresentationLuxury Real Estate Listing Presentation
Luxury Real Estate Listing Presentation
 
25 Real Estate Marketing Ideas The Pro's Use
25 Real Estate Marketing Ideas The Pro's Use25 Real Estate Marketing Ideas The Pro's Use
25 Real Estate Marketing Ideas The Pro's Use
 
Listing presentation Dawn Bahr
Listing presentation Dawn BahrListing presentation Dawn Bahr
Listing presentation Dawn Bahr
 
3 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 20173 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 2017
 

Similaire à C programming language working with functions 1

Similaire à C programming language working with functions 1 (20)

CH.4FUNCTIONS IN C_FYBSC(CS).pptx
CH.4FUNCTIONS IN C_FYBSC(CS).pptxCH.4FUNCTIONS IN C_FYBSC(CS).pptx
CH.4FUNCTIONS IN C_FYBSC(CS).pptx
 
Functions
Functions Functions
Functions
 
cp Module4(1)
cp Module4(1)cp Module4(1)
cp Module4(1)
 
unit3 part2 pcds function notes.pdf
unit3 part2 pcds function notes.pdfunit3 part2 pcds function notes.pdf
unit3 part2 pcds function notes.pdf
 
Ch4 functions
Ch4 functionsCh4 functions
Ch4 functions
 
Function in c
Function in cFunction in c
Function in c
 
User defined function in C.pptx
User defined function in C.pptxUser defined function in C.pptx
User defined function in C.pptx
 
Functions
FunctionsFunctions
Functions
 
FUNCTIONS IN C PROGRAMMING.pdf
FUNCTIONS IN C PROGRAMMING.pdfFUNCTIONS IN C PROGRAMMING.pdf
FUNCTIONS IN C PROGRAMMING.pdf
 
C function
C functionC function
C function
 
Unit-III.pptx
Unit-III.pptxUnit-III.pptx
Unit-III.pptx
 
Lecture 11 - Functions
Lecture 11 - FunctionsLecture 11 - Functions
Lecture 11 - Functions
 
Chapter_1.__Functions_in_C++[1].pdf
Chapter_1.__Functions_in_C++[1].pdfChapter_1.__Functions_in_C++[1].pdf
Chapter_1.__Functions_in_C++[1].pdf
 
Chapter 1. Functions in C++.pdf
Chapter 1.  Functions in C++.pdfChapter 1.  Functions in C++.pdf
Chapter 1. Functions in C++.pdf
 
Chapter 13.1.6
Chapter 13.1.6Chapter 13.1.6
Chapter 13.1.6
 
Function in c
Function in cFunction in c
Function in c
 
Function C programming
Function C programmingFunction C programming
Function C programming
 
[ITP - Lecture 12] Functions in C/C++
[ITP - Lecture 12] Functions in C/C++[ITP - Lecture 12] Functions in C/C++
[ITP - Lecture 12] Functions in C/C++
 
Functions assignment
Functions assignmentFunctions assignment
Functions assignment
 
Module 3-Functions
Module 3-FunctionsModule 3-Functions
Module 3-Functions
 

Dernier

WhatsApp 📞 8448380779 ✅Call Girls In Salarpur Sector 81 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Salarpur Sector 81 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Salarpur Sector 81 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Salarpur Sector 81 ( Noida)Delhi Call girls
 
Call Girls Alandi Road Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Alandi Road Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Alandi Road Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Alandi Road Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
TEST BANK For An Introduction to Brain and Behavior, 7th Edition by Bryan Kol...
TEST BANK For An Introduction to Brain and Behavior, 7th Edition by Bryan Kol...TEST BANK For An Introduction to Brain and Behavior, 7th Edition by Bryan Kol...
TEST BANK For An Introduction to Brain and Behavior, 7th Edition by Bryan Kol...rightmanforbloodline
 
reStartEvents 5:9 DC metro & Beyond V-Career Fair Employer Directory.pdf
reStartEvents 5:9 DC metro & Beyond V-Career Fair Employer Directory.pdfreStartEvents 5:9 DC metro & Beyond V-Career Fair Employer Directory.pdf
reStartEvents 5:9 DC metro & Beyond V-Career Fair Employer Directory.pdfKen Fuller
 
➥🔝 7737669865 🔝▻ Bulandshahr Call-girls in Women Seeking Men 🔝Bulandshahr🔝 ...
➥🔝 7737669865 🔝▻ Bulandshahr Call-girls in Women Seeking Men  🔝Bulandshahr🔝  ...➥🔝 7737669865 🔝▻ Bulandshahr Call-girls in Women Seeking Men  🔝Bulandshahr🔝  ...
➥🔝 7737669865 🔝▻ Bulandshahr Call-girls in Women Seeking Men 🔝Bulandshahr🔝 ...amitlee9823
 
Presentation for the country presentation
Presentation for the country presentationPresentation for the country presentation
Presentation for the country presentationjalal879
 
Brand Analysis for reggaeton artist Jahzel.
Brand Analysis for reggaeton artist Jahzel.Brand Analysis for reggaeton artist Jahzel.
Brand Analysis for reggaeton artist Jahzel.GabrielaMiletti
 
Call Girls Hosur Road Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hosur Road Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hosur Road Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hosur Road Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...amitlee9823
 
Call Girls In Kengeri Satellite Town ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Kengeri Satellite Town ☎ 7737669865 🥵 Book Your One night StandCall Girls In Kengeri Satellite Town ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Kengeri Satellite Town ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
Jual obat aborsi Jakarta ( 085657271886 )Cytote pil telat bulan penggugur kan...
Jual obat aborsi Jakarta ( 085657271886 )Cytote pil telat bulan penggugur kan...Jual obat aborsi Jakarta ( 085657271886 )Cytote pil telat bulan penggugur kan...
Jual obat aborsi Jakarta ( 085657271886 )Cytote pil telat bulan penggugur kan...ZurliaSoop
 
Call Girls Devanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Devanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Devanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Devanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service B...amitlee9823
 
Guide to a Winning Interview May 2024 for MCWN
Guide to a Winning Interview May 2024 for MCWNGuide to a Winning Interview May 2024 for MCWN
Guide to a Winning Interview May 2024 for MCWNBruce Bennett
 
Call Girls Bidadi ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Call Girls Bidadi ☎ 7737669865☎ Book Your One night Stand (Bangalore)Call Girls Bidadi ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Call Girls Bidadi ☎ 7737669865☎ Book Your One night Stand (Bangalore)amitlee9823
 
➥🔝 7737669865 🔝▻ Mirzapur Call-girls in Women Seeking Men 🔝Mirzapur🔝 Escor...
➥🔝 7737669865 🔝▻ Mirzapur Call-girls in Women Seeking Men  🔝Mirzapur🔝   Escor...➥🔝 7737669865 🔝▻ Mirzapur Call-girls in Women Seeking Men  🔝Mirzapur🔝   Escor...
➥🔝 7737669865 🔝▻ Mirzapur Call-girls in Women Seeking Men 🔝Mirzapur🔝 Escor...amitlee9823
 
Miletti Gabriela_Vision Plan for artist Jahzel.pdf
Miletti Gabriela_Vision Plan for artist Jahzel.pdfMiletti Gabriela_Vision Plan for artist Jahzel.pdf
Miletti Gabriela_Vision Plan for artist Jahzel.pdfGabrielaMiletti
 
Nandini Layout Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
Nandini Layout Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...Nandini Layout Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
Nandini Layout Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...amitlee9823
 
Hyderabad 💫✅💃 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATIS...
Hyderabad 💫✅💃 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATIS...Hyderabad 💫✅💃 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATIS...
Hyderabad 💫✅💃 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATIS...sonalitrivedi431
 
Personal Brand Exploration - Fernando Negron
Personal Brand Exploration - Fernando NegronPersonal Brand Exploration - Fernando Negron
Personal Brand Exploration - Fernando Negronnegronf24
 
Call Girls Jayanagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jayanagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...Call Girls Jayanagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jayanagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...amitlee9823
 
Personal Brand Exploration ppt.- Ronnie Jones
Personal Brand  Exploration ppt.- Ronnie JonesPersonal Brand  Exploration ppt.- Ronnie Jones
Personal Brand Exploration ppt.- Ronnie Jonesjonesyde302
 

Dernier (20)

WhatsApp 📞 8448380779 ✅Call Girls In Salarpur Sector 81 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Salarpur Sector 81 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Salarpur Sector 81 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Salarpur Sector 81 ( Noida)
 
Call Girls Alandi Road Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Alandi Road Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Alandi Road Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Alandi Road Call Me 7737669865 Budget Friendly No Advance Booking
 
TEST BANK For An Introduction to Brain and Behavior, 7th Edition by Bryan Kol...
TEST BANK For An Introduction to Brain and Behavior, 7th Edition by Bryan Kol...TEST BANK For An Introduction to Brain and Behavior, 7th Edition by Bryan Kol...
TEST BANK For An Introduction to Brain and Behavior, 7th Edition by Bryan Kol...
 
reStartEvents 5:9 DC metro & Beyond V-Career Fair Employer Directory.pdf
reStartEvents 5:9 DC metro & Beyond V-Career Fair Employer Directory.pdfreStartEvents 5:9 DC metro & Beyond V-Career Fair Employer Directory.pdf
reStartEvents 5:9 DC metro & Beyond V-Career Fair Employer Directory.pdf
 
➥🔝 7737669865 🔝▻ Bulandshahr Call-girls in Women Seeking Men 🔝Bulandshahr🔝 ...
➥🔝 7737669865 🔝▻ Bulandshahr Call-girls in Women Seeking Men  🔝Bulandshahr🔝  ...➥🔝 7737669865 🔝▻ Bulandshahr Call-girls in Women Seeking Men  🔝Bulandshahr🔝  ...
➥🔝 7737669865 🔝▻ Bulandshahr Call-girls in Women Seeking Men 🔝Bulandshahr🔝 ...
 
Presentation for the country presentation
Presentation for the country presentationPresentation for the country presentation
Presentation for the country presentation
 
Brand Analysis for reggaeton artist Jahzel.
Brand Analysis for reggaeton artist Jahzel.Brand Analysis for reggaeton artist Jahzel.
Brand Analysis for reggaeton artist Jahzel.
 
Call Girls Hosur Road Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hosur Road Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hosur Road Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hosur Road Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
 
Call Girls In Kengeri Satellite Town ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Kengeri Satellite Town ☎ 7737669865 🥵 Book Your One night StandCall Girls In Kengeri Satellite Town ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Kengeri Satellite Town ☎ 7737669865 🥵 Book Your One night Stand
 
Jual obat aborsi Jakarta ( 085657271886 )Cytote pil telat bulan penggugur kan...
Jual obat aborsi Jakarta ( 085657271886 )Cytote pil telat bulan penggugur kan...Jual obat aborsi Jakarta ( 085657271886 )Cytote pil telat bulan penggugur kan...
Jual obat aborsi Jakarta ( 085657271886 )Cytote pil telat bulan penggugur kan...
 
Call Girls Devanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Devanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Devanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Devanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Guide to a Winning Interview May 2024 for MCWN
Guide to a Winning Interview May 2024 for MCWNGuide to a Winning Interview May 2024 for MCWN
Guide to a Winning Interview May 2024 for MCWN
 
Call Girls Bidadi ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Call Girls Bidadi ☎ 7737669865☎ Book Your One night Stand (Bangalore)Call Girls Bidadi ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Call Girls Bidadi ☎ 7737669865☎ Book Your One night Stand (Bangalore)
 
➥🔝 7737669865 🔝▻ Mirzapur Call-girls in Women Seeking Men 🔝Mirzapur🔝 Escor...
➥🔝 7737669865 🔝▻ Mirzapur Call-girls in Women Seeking Men  🔝Mirzapur🔝   Escor...➥🔝 7737669865 🔝▻ Mirzapur Call-girls in Women Seeking Men  🔝Mirzapur🔝   Escor...
➥🔝 7737669865 🔝▻ Mirzapur Call-girls in Women Seeking Men 🔝Mirzapur🔝 Escor...
 
Miletti Gabriela_Vision Plan for artist Jahzel.pdf
Miletti Gabriela_Vision Plan for artist Jahzel.pdfMiletti Gabriela_Vision Plan for artist Jahzel.pdf
Miletti Gabriela_Vision Plan for artist Jahzel.pdf
 
Nandini Layout Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
Nandini Layout Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...Nandini Layout Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
Nandini Layout Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
 
Hyderabad 💫✅💃 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATIS...
Hyderabad 💫✅💃 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATIS...Hyderabad 💫✅💃 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATIS...
Hyderabad 💫✅💃 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATIS...
 
Personal Brand Exploration - Fernando Negron
Personal Brand Exploration - Fernando NegronPersonal Brand Exploration - Fernando Negron
Personal Brand Exploration - Fernando Negron
 
Call Girls Jayanagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jayanagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...Call Girls Jayanagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jayanagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
 
Personal Brand Exploration ppt.- Ronnie Jones
Personal Brand  Exploration ppt.- Ronnie JonesPersonal Brand  Exploration ppt.- Ronnie Jones
Personal Brand Exploration ppt.- Ronnie Jones
 

C programming language working with functions 1

  • 1. C ProgrammingLanguage WorkingwithFunctions1 Agenda: What is a Functions? A function is a named, independent section of C code that performs a specific task and optionally returns a value to the callingprogram A function is named. Each function has a unique name. By usingthat name in another partof the program, you can execute the statements contained in the function.This is known as callingthefunction. A function can be called fromwithin another function. A function is independent. A function can perform its task without interference from or interferingwith other parts of the program. A function performs a specific task. This is the easy partof the definition.A task is a discretejob that your program must perform as partof its overall operation,such as sendinga lineof text to a printer, sortingan array into numerical order,or calculatinga cuberoot. function can return a value to the calling program. When your program callsa function,the statements it contains areexecuted. If you want them to, these statements can pass information back to the callingprogram. Benefits of the functions program Function Terminology Function prototype: A function's prototype contains the name of the function,return type, a lis tof variables that must be passed to it, and the type of variableitreturns, if any.. Function Definition: The function itself is called the function definition.The definition contains the code that will be executed. C ProgrammingLanguage WorkingwithFunctions2
  • 2. Function header: The function header is atthe startof a function,and itgives the function's name. The header also gives the function's return type and describes its arguments.Note that the function header is identical to the function prototype (minus the semicolon). Function Body: The statements written within function arecalled function body. Statements are enclosed in braces.These statements are executed when the function is called. Arguments: When a function is called,the program can send the function information in the form of one or more arguments. An argument is programdata needed by the function to perform its task.Arguments are enclosed in parentheses followingthe function's name. Return statement: If the function return type is anythingother than void, a return statement should be included, returning a valuematching the return type. /* Demonstrates a simple function */ #include<stdio.h> longcube(long x); longinput, answer; main() { printf("Enter an integer value: "); scanf("%d", &input); answer = cube(input); /*here input is actual argument. /* Note: %ld is the conversion specifier for */ /* a long integer */ printf("nThe cube of %ld is %ld.n", input, answer); return 0; } /* Function: cube() - Calculates thecubed valueof a variable*/ longcube(long x) /*here x is formal argument*/ { longx_cubed; x_cubed = x * x * x; return x_cubed; } How does a Function Works program. C ProgrammingLanguage WorkingwithFunctions3
  • 3. m of one or more arguments. An argument is programdata needed by the function to perform its task.The statements in the function then execute, performing whatever task each was designed to do. sses back to the same location in the program that called the function. Functions can send information back to the program in the form of a return value. xecution passes back to the placefrom which the function was called.A function can be called as many times as needed, and functions can be called in any order. #include<stdio.h> void printline(char ch,intn); int add(inta,intb,int c); main() { int result; printline('#',70); result=add(10,3,4); printf("n resultis %d",result); getch(); return 0; } void printline(char ch,intn) { int i; for(i=0;i<n;i++) printf("%c",ch); } int add(inta,intb,int c) { C ProgrammingLanguage WorkingwithFunctions4
  • 4. return a+b+c; } /* Program to check the given value is vowel */ #include<stdio.h> void main() { char ch; printf("nEnter any character …'); ch=getch(); if(checkvowel(ch)==1) printf("n It is a vowel"); else printf("n try again"); } int checkvowel(char ch) { if(ch=='a'||ch=='c'||ch=='i'||ch=='o'||ch=='u'||ch='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U') return (1); else return (0); }