Monday, April 1, 2013

The stars2 function using a prototype

The same function as before but with a prototype declared at the top of the program.

/* A function with a prototype */
/* You can put only the prototype (header) on top */ /* and define the function at the bottom */ #include <stdio.h> /* the function prototype */ void stars2 (int n); /* the main program */ int main (void) { int a; a=10; /* the argument may be a constant, a variable or an expression */ stars2 (20); stars2 (a); stars2 (a+2); return (0); } /* the function definition */ void stars2 (int n) { int i; /* a loop displaying a star at each iteration */ for (i=1; i<=n; ++i) { printf ("*"); } /* change line after each series */ printf ("\n"); }
Legend: preprocessor directives | variable declarations | main program | helper functions | user-defined structures | comments
********************
**********
************

1 comment:

  1. Ff 1/2 ford transit connect titanium - iTanium
    Ff 1/2 ford transit connect titanium Ff 1/2 ford titanium mountain bikes transportation connect ford escape titanium titanium. titanium easy flux 125 amp welder Photo Credit: thaitanium Ff1/2 titanium nitride ford transportation connect

    ReplyDelete