Create a function that types 40 asterisks in a row. - C Function

C examples for Function:Function Definition

Description

Create a function that types 40 asterisks in a row.

Demo Code

#include <stdio.h> 
#define NAME "BOOK2s.COM, INC." 
#define ADDRESS "101 Main St." 
#define PLACE "L.A., CA 94904" 
#define WIDTH 40 /* w  w w  .  j  av  a 2s .  c  o  m*/
   
void starbar(void);  /* prototype the function */ 
   
int main(void) 
{ 
    starbar(); 
    printf("%s\n", NAME); 
    printf("%s\n", ADDRESS); 
    printf("%s\n", PLACE); 
    starbar();       /* use the function       */ 
   
    return 0; 
} 
   
void starbar(void)   /* define the function    */ 
{ 
    int count; 
   
    for (count = 1; count <= WIDTH; count++) 
        putchar('*'); 
    putchar('\n'); 
}

Related Tutorials