Thread: Explanation to a note.

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    5

    Explanation to a note.

    Hey there,I was reading a note and I came up across a couple of things I'd like to have explained to me.
    My first question is, what is the purpose of the 2 besides the star on line 6 and the bracketed "int n"? Thanks in advance. This is not an assignment,just a note from the internet.

    Code:
    /* A void function with one argument */
    #include <stdio.h>
    
    /* a void function returns nothing */
    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"); 
    }
    
    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);
    }

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,739
    "stars2" is the function's name, while "int n" is it's argument. Functions in C
    Devoted my life to programming...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Random Note
    By MMD_Lynx in forum A Brief History of Cprogramming.com
    Replies: 28
    Last Post: 10-20-2004, 06:31 AM
  2. A polite note
    By chrismax2 in forum C++ Programming
    Replies: 4
    Last Post: 02-27-2003, 02:30 PM
  3. a note to those of you who drink
    By Aran in forum A Brief History of Cprogramming.com
    Replies: 92
    Last Post: 05-18-2002, 01:14 PM
  4. Note to self..
    By Brian in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 01-20-2002, 08:46 AM

Tags for this Thread