Function protorype
Enviado por qweasd1 • 20 de Diciembre de 2020 • Tarea • 514 Palabras (3 Páginas) • 150 Visitas
Function protorype:
return_type function_name (argument list)
{
Set of statements – Block of code
}
Example of cunction and use:
#include <stdio.h>
int SumNumbers(int a, int b); // function prototype; here you create the definition for the function
int main()
{
int n1,n2,sum;
printf("Enter two numbers: ");
scanf("%d %d",&n1,&n2);
sum = SumNumbers(n1, n2); // function call; here you call the function from the main, this funciont will do something.
printf("sum = %d",sum);
return 0;
}
int SumNumbers(int a, int b) // function definition this is the function that was prototyped above
{
int res;
res = a+b;
return res; // return statement; this will theturn the value res to the caller
}
Function protorype:
return_type function_name (argument list)
{
Set of statements – Block of code
}
Example of cunction and use:
#include <stdio.h>
int SumNumbers(int a, int b); // function prototype; here you create the definition for the function
int main()
{
int n1,n2,sum;
printf("Enter two numbers: ");
scanf("%d %d",&n1,&n2);
sum = SumNumbers(n1, n2); // function call; here you call the function from the main, this funciont will do something.
printf("sum = %d",sum);
return 0;
}
int SumNumbers(int a, int b) // function definition this is the function that was prototyped above
{
int res;
res = a+b;
return res; // return statement; this will theturn the value res to the caller
}
Function protorype:
return_type function_name (argument list)
{
Set of statements – Block of code
}
Example of cunction and use:
#include <stdio.h>
int SumNumbers(int a, int b); // function prototype; here you create the definition for the function
int main()
{
int n1,n2,sum;
printf("Enter two numbers: ");
scanf("%d %d",&n1,&n2);
sum = SumNumbers(n1, n2); // function call; here you call the function from the main, this funciont will do something.
printf("sum = %d",sum);
...