facebook like button

23 May, 2011

program 45: printing hello world with user defined function

The need: 
      This is program is just to print "Hello World !" on the standard output using User defined function.

The code: 
--------------------------------------------
#include<stdio.h>
void print_hello(void);       //declaration of function
int main()
{
  print_hello();
  return 0;
}
void print_hello(void)       //definition of function
{
  printf("Hello World!\n");
} 
--------------------------------------------

The approach: 
First of all copy, paste, compile and run the program. After that try to understand the code and also try to compare with code of program1 of this blog.

Remarks:
There are 2 noticeable points. 
1. The output of both the programs is same.
2. The only difference is in the code (that is in this I have used UDF.)

No comments:

Post a Comment

feel free to ask your doubts... if any
you can post your doubts on
www.facebook.com/programsimply