Sunday, October 2, 2016

C function with an argument and no return value.


//C function with an argument and no return value.

#include<stdio.h>

void print_line(int);

int main()
{
     print_line(2);  //this will pass 2 two print_line() function
    
     printf("Hello World\n");
    
     print_line(3);  //this will pass 3 two print_line() function
    
     return 0; 
}

void print_line(int n)
{
     int i;
     for(i=0; i<n; i++)
     {
           printf("------------\n"); 
     }
}


Output of the program:

------------
------------
Hello World
------------
------------
------------


No comments:

Post a Comment