SlideShare a Scribd company logo
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);
}

More Related Content

What's hot (20)

PPTX
User defined functions
Rokonuzzaman Rony
 
PPT
user defined function
King Kavin Patel
 
PPTX
User defined functions in C
Harendra Singh
 
PPTX
Functionincprogram
Sampath Kumar
 
PPT
Functions
Online
 
PPTX
Function & Recursion
Meghaj Mallick
 
PPTX
Function
rishabh agrawal
 
PDF
Pointers and call by value, reference, address in C
Syed Mustafa
 
PPTX
Function
Saniati
 
PPT
User Defined Functions
Praveen M Jigajinni
 
PPTX
Function Parameters
primeteacher32
 
PPT
Functions
PatriciaPabalan
 
PDF
Modular Programming in C
bhawna kol
 
PPTX
Method parameters in c#
Dr.Neeraj Kumar Pandey
 
PPT
Functions in c++
Maaz Hasan
 
PPTX
Function in c++
Kumar
 
PPT
Basic information of function in cpu
Dhaval Jalalpara
 
PDF
C language for Semester Exams for Engineers
Appili Vamsi Krishna
 
PPT
Function
Rajat Patel
 
User defined functions
Rokonuzzaman Rony
 
user defined function
King Kavin Patel
 
User defined functions in C
Harendra Singh
 
Functionincprogram
Sampath Kumar
 
Functions
Online
 
Function & Recursion
Meghaj Mallick
 
Function
rishabh agrawal
 
Pointers and call by value, reference, address in C
Syed Mustafa
 
Function
Saniati
 
User Defined Functions
Praveen M Jigajinni
 
Function Parameters
primeteacher32
 
Functions
PatriciaPabalan
 
Modular Programming in C
bhawna kol
 
Method parameters in c#
Dr.Neeraj Kumar Pandey
 
Functions in c++
Maaz Hasan
 
Function in c++
Kumar
 
Basic information of function in cpu
Dhaval Jalalpara
 
C language for Semester Exams for Engineers
Appili Vamsi Krishna
 
Function
Rajat Patel
 

Viewers also liked (11)

PDF
South Florida Real Estate 2017 Outlook Survey
cutmytaxes
 
DOC
A non residents guide to buying property in florida
James Lavigne
 
PDF
Make It Happen Homes Listing Presentation for North Texas Real Estate
Mary Lou Jaimes
 
PDF
La Jolla Agent Listing Presentation
ProFund Real Estate, Inc.
 
PPT
Listing Presentation
LenneaA
 
PPTX
Real Estate Listing Presentation
The Charlotte House Hunter Group
 
PPTX
Realty Elite | Listing Presentation
Realty Elite
 
PDF
Luxury Real Estate Listing Presentation
Gary Grimes
 
PDF
25 Real Estate Marketing Ideas The Pro's Use
Fit Small Business
 
PPTX
Listing presentation Dawn Bahr
Dawn Bahr
 
PDF
3 Things Every Sales Team Needs to Be Thinking About in 2017
Drift
 
South Florida Real Estate 2017 Outlook Survey
cutmytaxes
 
A non residents guide to buying property in florida
James Lavigne
 
Make It Happen Homes Listing Presentation for North Texas Real Estate
Mary Lou Jaimes
 
La Jolla Agent Listing Presentation
ProFund Real Estate, Inc.
 
Listing Presentation
LenneaA
 
Real Estate Listing Presentation
The Charlotte House Hunter Group
 
Realty Elite | Listing Presentation
Realty Elite
 
Luxury Real Estate Listing Presentation
Gary Grimes
 
25 Real Estate Marketing Ideas The Pro's Use
Fit Small Business
 
Listing presentation Dawn Bahr
Dawn Bahr
 
3 Things Every Sales Team Needs to Be Thinking About in 2017
Drift
 
Ad

Similar to C programming language working with functions 1 (20)

PPTX
unit_2 (1).pptx
JVenkateshGoud
 
PPTX
Function in c program
umesh patil
 
PPTX
FUNCTIONS IN C.pptx
SKUP1
 
PPTX
FUNCTIONS IN C.pptx
LECO9
 
PDF
Functions
Pragnavi Erva
 
PPT
Lecture6
Dr. Kavita Sharma
 
PDF
unit3 part2 pcds function notes.pdf
JAVVAJI VENKATA RAO
 
PPTX
FUNCTIONengineeringtechnologyslidesh.pptx
ricknova674
 
PPTX
C function
thirumalaikumar3
 
PPTX
User defined function in C.pptx
Rhishav Poudyal
 
PDF
Programming in C Functions PPT Presentation.pdf
Ramesh Wadawadagi
 
PPTX
unit_2.pptx
Venkatesh Goud
 
PPTX
C functions
University of Potsdam
 
PDF
VIT351 Software Development VI Unit1
YOGESH SINGH
 
PPTX
CH.4FUNCTIONS IN C_FYBSC(CS).pptx
SangeetaBorde3
 
PPTX
Presentation on Function in C Programming
Shuvongkor Barman
 
PDF
Presentation 2 (1).pdf
ziyadaslanbey
 
PPTX
Functions in C.pptx
Ashwini Raut
 
PPTX
Detailed concept of function in c programming
anjanasharma77573
 
PPTX
Functions in c language
tanmaymodi4
 
unit_2 (1).pptx
JVenkateshGoud
 
Function in c program
umesh patil
 
FUNCTIONS IN C.pptx
SKUP1
 
FUNCTIONS IN C.pptx
LECO9
 
Functions
Pragnavi Erva
 
unit3 part2 pcds function notes.pdf
JAVVAJI VENKATA RAO
 
FUNCTIONengineeringtechnologyslidesh.pptx
ricknova674
 
C function
thirumalaikumar3
 
User defined function in C.pptx
Rhishav Poudyal
 
Programming in C Functions PPT Presentation.pdf
Ramesh Wadawadagi
 
unit_2.pptx
Venkatesh Goud
 
VIT351 Software Development VI Unit1
YOGESH SINGH
 
CH.4FUNCTIONS IN C_FYBSC(CS).pptx
SangeetaBorde3
 
Presentation on Function in C Programming
Shuvongkor Barman
 
Presentation 2 (1).pdf
ziyadaslanbey
 
Functions in C.pptx
Ashwini Raut
 
Detailed concept of function in c programming
anjanasharma77573
 
Functions in c language
tanmaymodi4
 
Ad

Recently uploaded (20)

PPTX
maths analysis saktffy shfshshhhnew.pptx
yuxshanyoga
 
PPTX
Adaptive Leadership Model 2025 – AI-Generated PowerPoint by Presentify.ai
presentifyai
 
PPTX
Web Developer Jobs in Jaipur Your Gateway to a Thriving Tech Career in Rajast...
vinay salarite
 
PDF
The Rising Prominence of Podcasts Today
Raj Kumble
 
PPTX
Learn AI in Software Testing - Venkatesh (Rahul Shetty)
Venkatesh (Rahul Shetty)
 
PPTX
原版英国牛津大学毕业证(Oxon毕业证书)如何办理
Taqyea
 
PPTX
The Future of Law.ppptttttttttttttttttttttttttttttttttttttttttttttttttttttttt...
sahatanmay391
 
PDF
Convex optimization analysis in todays world scenario.pdf
mahizxy
 
PPTX
21st-Literature.pptxjsududhshsusushshsusuhsgsysh
JohnVJLBellen
 
PDF
VisionIAS - UPSC GS Paper I Question Paper 2025 with Answer Key.pdf
saxenashubh937
 
PPTX
A Guide for a Winning Interview July 2025
Bruce Bennett
 
PPTX
Plant Growth and Development-Part I, ppt.pptx
7300511143
 
PPT
SQL.pptkarim pfe rabatkarim pfe rabatkarim pfe rabat
Keeyvikyv
 
PPTX
A Portfolio as a Job Search Tool July 2025
Bruce Bennett
 
PDF
Walking &Working Surfaces – Stairs & Ladders.pdf
دكتور تامر عبدالله شراكى
 
PDF
Buy Twitter Accounts_ Boost Your Brand and Reach in 2025 - Copy - Copy.pdf
Buy Old Twitter Accounts-100% Secure Aged With Followers
 
DOCX
PMCF (Performance Monitoring and Coaching Form
ROSALIESOMBILON
 
PDF
Rediscovering Classic Illustration Techniques.pdf
Bruno Amezcua
 
PPTX
5G Model Site PPT WBA179_ROB_Ghorai (1).pptx
kousikmaity15
 
PDF
Smarter Private Job Search Starts with Formwalaa
Reeshna Prajeesh
 
maths analysis saktffy shfshshhhnew.pptx
yuxshanyoga
 
Adaptive Leadership Model 2025 – AI-Generated PowerPoint by Presentify.ai
presentifyai
 
Web Developer Jobs in Jaipur Your Gateway to a Thriving Tech Career in Rajast...
vinay salarite
 
The Rising Prominence of Podcasts Today
Raj Kumble
 
Learn AI in Software Testing - Venkatesh (Rahul Shetty)
Venkatesh (Rahul Shetty)
 
原版英国牛津大学毕业证(Oxon毕业证书)如何办理
Taqyea
 
The Future of Law.ppptttttttttttttttttttttttttttttttttttttttttttttttttttttttt...
sahatanmay391
 
Convex optimization analysis in todays world scenario.pdf
mahizxy
 
21st-Literature.pptxjsududhshsusushshsusuhsgsysh
JohnVJLBellen
 
VisionIAS - UPSC GS Paper I Question Paper 2025 with Answer Key.pdf
saxenashubh937
 
A Guide for a Winning Interview July 2025
Bruce Bennett
 
Plant Growth and Development-Part I, ppt.pptx
7300511143
 
SQL.pptkarim pfe rabatkarim pfe rabatkarim pfe rabat
Keeyvikyv
 
A Portfolio as a Job Search Tool July 2025
Bruce Bennett
 
Walking &Working Surfaces – Stairs & Ladders.pdf
دكتور تامر عبدالله شراكى
 
Buy Twitter Accounts_ Boost Your Brand and Reach in 2025 - Copy - Copy.pdf
Buy Old Twitter Accounts-100% Secure Aged With Followers
 
PMCF (Performance Monitoring and Coaching Form
ROSALIESOMBILON
 
Rediscovering Classic Illustration Techniques.pdf
Bruno Amezcua
 
5G Model Site PPT WBA179_ROB_Ghorai (1).pptx
kousikmaity15
 
Smarter Private Job Search Starts with Formwalaa
Reeshna Prajeesh
 

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); }