Defines a function with an argument - C Function

C examples for Function:Function Definition

Description

Defines a function with an argument

Demo Code

#include <stdio.h>

void pound(int n);   // ANSI function prototype declaration

int main(void){
    int times = 5;
    char ch = '!';   // ASCII code is 33
    float f = 6.0f;
    //from  www .  ja  v a 2  s.  co m
    pound(times);    // int argument
    pound(ch);       // same as pound((int)ch);
    pound(f);        // same as pound((int)f);
    
    return 0;
}

void pound(int n)    
{                    
    while (n-- > 0)
        printf("#");
    printf("\n");
}

Related Tutorials