A program to multiplication two numbers using Function with arguments, return type

Multiplication two numbers using Function  with arguments, return type




            In this example, we will understand to perform multiplication two numbers using Function  with arguments, return type and know how to write, compile and debug it in C language and also learn how to implement it in c.

        
        In order to do this you will need
  • Basic knowledge of c programming language.
  • As well as know how to operate codeblocks.   
          
           Here there is a two-way data communication between the calling and the called function.


So let's begin with our program

1.Open a codeblocks software.

2.Open new empty file.

3.Copy and paste the code from below. 


A program to multiplication two numbers using Function  with arguments, return type,c programming language,2021,basic codes,input output code



Declaring a function or prototype:

The general structure of a function declaration is as follows:
  
return_type function_name(arguments); 
Before defining a function, it is required to declare the function i.e. to specify the function
prototype. A function declaration is followed by a semicolon " ; ". Unlike the function
definition only data type are to be mentioned for arguments in the function declaration.
 
Calling a function:

The function call is made as follows:
function_name(arguments);
 
Defining a function:

All the statements or the operations to be performed by a function are given in the function
definition which is normally given at the end of the program outside the main.
Function is defined as follows
return_type function_name(arguments)
{
Statements;
           }


Input code-

//multiplication by function with arguments, return type

#include<stdio.h>
int mul(int x, int y);
int main()
{
 int m,x,y;
 printf("\nEnter two numbers:");
 scanf("%d%d",&x,&y);
 m=mul(x,y);
 printf("\nMultiplication=%d",m);
 return 0;
}

int mul(int x, int y)
{
 int p;
 p=x*y;
 return(p);
}




Now simply build the code. Look for any error. Now run the code.

For output enter any two number you want to multiply and press enter key.


A program to multiplication two numbers using Function  with arguments, return type,c programming language,2021,basic codes,input output code



Click the following button to download A program to multiplication two numbers using Function  with arguments, return type






Thats it.Thank you for scrolling.





Post a Comment

If you have any doubt or suggestions.please let me know.

Previous Post Next Post

Ads by google

Ads by google