c functions

[ad_1]

c functions example
#include 
int addNumbers(int a, int b);         // function prototype

int main()
{
    int n1,n2,sum;

    printf("Enters two numbers: ");
    scanf(

    sum = addNumbers(n1, n2);        // function call
    printf("sum =

    return 0;
}

int addNumbers(int a, int b)         // function definition
{
    int result;
    result = a+b;
    return result;                  // return statement
}
declare function in c
#include 

// Create a function
void myFunction() {
        printf("I just got executed!\n");
}

int main() {
        myFunction(); // call the function
        return 0;
}
c define function
//INCLUDING BUILT-IN LIBRARIES...
#include 
#include 
//PRE-DEFINE CONSTANT VALUES...
#define MAXNUM -12    //defining an integer
#define PI 3.1415     //defining a float
#define END "\n\n\t\tProgram has ended!!\n"   //defining a string
//PRE-DEFINING CONSTANT OPERATIONS...
#define ADD(a, b, c) (a + b + c)    //Operation that will add its 3 parameters

int main(){
    //using other definitions to check if the current device is Windows or UNIX
    #ifdef _WIN32
        printf("\nWindows Operating System Detected\n");
    #elif linux
        printf("\nUNIX Operating System Detected\n");
    #else
        printf("\nOperating System could NOT be identified!\n");
    #endif

    printf("\nUsing pre-defined values and operations: ");
    printf("\n • MAXNUM:
    printf("\n • PI:
    printf("\n • ADD():

    printf(END);    //using pre-defined string
    return 0;
}
c functions
#include 
void functionName()
{
    ... .. ...
    ... .. ...
}

int main()
{
    ... .. ...
    ... .. ...

    functionName();

    ... .. ...
    ... .. ...
}

[ad_2]

Please follow and like us:
Content Protection by DMCA.com