Your SlideShare is downloading. ×
0
Functions and return type
Functions and return type
Functions and return type
Functions and return type
Functions and return type
Functions and return type
Functions and return type
Functions and return type
Functions and return type
Functions and return type
Functions and return type
Functions and return type
Functions and return type
Functions and return type
Functions and return type
Functions and return type
Functions and return type
Functions and return type
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Functions and return type

123

Published on

Functions and return type

Functions and return type

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
123
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring Partner Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
  • 2. FUNCTIONS Shanu k k shanukk89@gmail.com www.facebook.com/shanunn i twitter.com/shanu in.linkedin.com/in/shanu 9656153432
  • 3. • one of the strengths of c language is c functions,they are easy to define and use • C function can be classified in to two catagories • 1 library function :printf and scanf • 2 user defind function: main
  • 4. Need for user defined function • Main is specially recoganized function in c,every program must have a main function to indicate where the program has to be execution • If a program condain only main function number of problem,testing and maintaining become difficult
  • 5. • Program is divided in to functional part ,which is independently coded and later combined in to a single unit • This independently coded programs are called sub programs are referred as function
  • 6. Main program Function A Function B Function c B1 b2
  • 7. Definition of function • function name • Function type • List of parameters • Local variable declaration • Function statement • Return statement
  • 8. Function_type function _name(parameter list) { local variable declaration; executable statement1; executable statement2; ………………………………….. return statement; }
  • 9. Function header • Type specifies type of value that expected to return eg:int,float • Void:function not return anything • name is valid c identifier • Same rule for other variable name in c
  • 10. Formal parameter list • Input data to the function and carry out the specified task • Also used to send values to the calling programs • also known as arguments
  • 11. Function body • Float mul ( float flt_ x ,float flt_ y) { float result; /*local variable*/ result=flt_x*flt_y; /*compute the mul*/ return (result); }
  • 12. • void display (void) { printf(“no type,no parameter”) ; } • Void sum( int int_ a,int int_b) { printf (“sum is %d,a+b);
  • 13. Return values and their type • Return; or return(expression);
  • 14. Main() { int y; Y=mul(10,5) /call/ } int mul (int x,int y) { int p; p=x*y; return(p); }
  • 15. Function declaration • Function name • Function type • Parameter list • Terminating semicolon int add (int x,int y);
  • 16. • Declaration placed two places in program 1. Above all the function including main 2. Inside a function definition
  • 17. Contact Us Emarald Mall (Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Start up Village Eranakulam, Kerala, India. Email: info@baabtra.com

×