Problem Solving using C Language

0 of 77 lessons complete (0%)

Functions

Function Call by Value

#include <stdio.h>

void func1(int a)
{
    printf("\nIn func1 the value of a is: %d",a);
}

void func2(int b)
{
    printf("\nIn func2 the value of a is: %d",b);
}

int main()
{
    int x=10;
    printf("In Func Main");
    func1(x);
    func2(x);
    func1(x);
    return 0;
}

Output:

In Func Main
In func1 the value of a is: 10
In func2 the value of a is: 10
In func1 the value of a is: 10

Program: Multiplication two numbers using function Call with Arguments

#include <stdio.h>

int multiply(int a, int b) 
{
    int c=0;
    c=a*b;
    return c;
}

int main() {
    int num1 = 6, num2 = 7;
    int result=0;
    result = multiply(num1, num2);
    printf("Multiplication: %d\n", result);
    return 0;
}