ClubEnsayos.com - Ensayos de Calidad, Tareas y Monografias
Buscar

Function protorype


Enviado por   •  20 de Diciembre de 2020  •  Tareas  •  514 Palabras (3 Páginas)  •  129 Visitas

Página 1 de 3

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;

}

...

Descargar como (para miembros actualizados)  txt (2.4 Kb)   pdf (31.8 Kb)   docx (8.8 Kb)  
Leer 2 páginas más »
Disponible sólo en Clubensayos.com