Page 2 - Sample_test_Float
P. 2

Chapter 4




              Functions and Pointers













              5.1. Functions – User Defined Functions


              Real Time Examples
              •  We have got various functions in our body for doing specific tasks.
                   ◦ Heart for pumping blood in veins
                   ◦ Lungs for breathing
                   ◦ Eyes for vision
                   ◦ Legs for walking
                   ◦ Nose for smell
              Solutions
              Similarly in programming we need something to handle our repetitive or specific task that is called function.
              A function
              i)  accepts some input
              ii)  processes it
              iii) produces output.

              Function Concept in Mathematics
                                                         f(x) = 5x – 3

              where
                f is a function name
                x is an argument or input of a function
                5x-3 is a definition of a function.
              When x = 1,
                f(1) = 5(1) – 3
                f(1) = 2
                2 is the return value of the function.

              When x=2,
                f(2) = 5(2) – 3
                f(2) = 7
                7 is the return value of the function.
              So, every function must have name, argument (input) and return (output) type.








              2  Functions and Pointers
   1   2   3   4   5   6   7