# int question

• 12-09-2001
Raian
int question
somewhere in the tutioral for this site i think the function page i saw a thing that says

int mult(int x, int y);

i was wondering why they used this? isnt it the same as doing

int x;
int y;

:confused:
• 12-09-2001
SushiFugu
Mult function
I'll try to clear things up..

What I think you are referring to there, is a function prototype. I think that one (if I remember the tutorials correctly) is a function that multiplies two numbers.

Although it looks somewhat like a variable declaration, its actually a prototype for a function (function is kinda like a little snippet of code that can be called)

The reason that is used, is because that function takes two arguments (x, y) and multiplies them.

I'm not gonna go into all the details of the uses of functions, and how they work, just cause.. well, theres already a tutorial on that.

I hope that helped somewhat :)
• 12-09-2001
maes
int mult(int x, int y);

you use this if you want to pass some numbers to the function.
take the multiply example. lets say you want to multiply to numbers entered by the user. then you want to use those numbers in the function. so you need to give them to the function.
Code:

```#include <stdio.h> multiply(int x, int y);//this is the function prototype int main(void) { int a,b; scanf("%d",&a); scanf("%d",&b); multiply(a,b);//Call the function return 0; } multiply(int x, int y) {//x contains the value of a and y contains the value of b int result; result=x*y; printf("the result is %d",result); return; }```