A function is a group of statements that together perform a task. Every C program has at least one function, which is main(), and all the most trivial programs can define additional functions.
#include<stdio.h> float square ( float x ); //function declaration int main( ) // main function { float m, n ; printf ( "\nEnter some number for finding square \n"); scanf ( "%f", &m ) ; n = square ( m ) ; // function call printf ( "\nSquare of the given number %f is %f",m,n ); } float square ( float x ) // function definition { float p ; p = x * x ; return ( p ) ; }
Enter some number for finding square 2 Square of the given number 2.000000 is 4.000000
Comments :