I got a question about style. I know that this area can be dangerous because its mostly dependent on someones own personal opinion on what should be correct and what is not. I'm trying to find the best solution and make my code as best matched to the standard as possible. But enough of that lets get to my question
here is some code like i have been instructed on writing a function
Code:
include<stdio.h>
void somefunction(int ,int );
int main()
{
int a,b;
a = 5;
b = 3;
somefunction(a,b);
return 0;
}
void somefunction(int x, int y)
{
int z;
z = x + y;
printf("Value is:%d\n",z);
} /* No return statement needed because there is only a void return on the fuction */
my question really is is there any reason you couldn't write the first part like this. (see below)
Code:
include<stdio.h>
void somefunction(int x,int y )
{
int z;
z = x + y;
printf("Value is:%d\n",z);
}
int main()
{
int a,b;
a = 5;
b = 3;
somefunction(a,b);
return 0;
}