Print letter using local variable - C Function

C examples for Function:Function Definition

Description

Print letter using local variable

Demo Code

#include <stdio.h>
void print_letter2(void);           /* function prototype */

int main( void )
{
    char letter1 = 'X';
    int ctr;//  w w w .j a va 2 s .c  om

    for( ctr = 0; ctr < 10; ctr++ )
    {
       printf( "%c", letter1 );
       print_letter2();
    }
    return 0;
}

void print_letter2(void)
{
    char letter2 = '=';
    int ctr;            /* this is a local variable */
                        /* it is different from ctr in main() */
    for( ctr = 0; ctr < 2; ctr++ )
        printf( "%c", letter2 );
}

Result


Related Tutorials