In: Computer Science
Given a program as shown below:
#include <stdio.h>
void function1(void);
void function2 (int, double x);
void main (void)
{
int m;
double y;
m=15;
y=308.24;
printf ("The value of m in main is m=%d\n\n",m);
function1();
function2(m,y);
printf ("The value of m is main still m = %d\n",m);
}
void function1(void)
{
printf("function1 is a void function that does not receive\n\\r values from main.\n\n");
}
void function2(int n, double x)
{
int k,m;
double z;
k=2*n+2;
m=5*n+37;
z=4.0*x-58.4;
printf ("function2 is a void function that does receive\n\\r values from main.The values received from main are:\n\\r\t n=%d \n\r\t x=%lf\n\n", n,x);
printf ("function2 creates three new variable, k, m and z\n\\rThese variable have the values:\n\\r\t 1=%d \n\r\t m=%d \n\r\t z=%lf \n\n",k,m,z);
}
Questions: Please use program given as example in explaination.
answer all the question please
1.) Is it necessary that main be the first function defined?
2.) Can a function prototype be written in a function body rather than outside the body of all functions?
3.) Is there any relationship between the variable m in main and the variable m in function2?
4.) Is there any relationship between the variable m in main and the variable m in function2?
5.) We used the printf function for this program. Why is there no function prototype for it?