Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __________________________________________________________________________________________________________
- INICIAL.C
- __________________________________________________________________________________________________________
- #include <stdio.h>
- #include <stdlib.h>
- void troca_int( int *valor1, int *valor2);
- void troca_float( float *valor1, float *valor2);
- int main( void) {
- int int1 = 200, int2 = 100;
- float pf1 = 2.5, pf2 = 1.5;
- troca_int( &int1, &int2);
- troca_float( &pf1, &pf2);
- printf( "Int1: %i, int2: %i, pf1: %f, pf2: %f\n\n", int1, int2, pf1, pf2);
- system( "PAUSE");
- return 0;
- }
- void troca_int( int *valor1, int *valor2) {
- int temp;
- temp = *valor1;
- *valor1 = *valor2;
- *valor2 = temp;
- }
- void troca_float( float *valor1, float *valor2) {
- float temp;
- temp = *valor1;
- *valor1 = *valor2;
- *valor2 = temp;
- }
- __________________________________________________________________________________________________________
- TROCA.C
- __________________________________________________________________________________________________________
- #include "troca.h"
- void troca_int( int *valor1, int *valor2) {
- int temp;
- temp = *valor1;
- *valor1 = *valor2;
- *valor2 = temp;
- }
- void troca_float( float *valor1, float *valor2) {
- float temp;
- temp = *valor1;
- *valor1 = *valor2;
- *valor2 = temp;
- }
- __________________________________________________________________________________________________________
- TROCA.H
- __________________________________________________________________________________________________________
- #ifndef TROCA_HEADER_
- #define TROCA_HEADER_
- void troca_int( int *valor1, int *valor2);
- void troca_float( float *valor1, float *valor2);
- #endif
- __________________________________________________________________________________________________________
- TESTE.C
- __________________________________________________________________________________________________________
- #include <stdio.h>
- #include <stdlib.h>
- #include "troca.h"
- int main( void) {
- int int1 = 200, int2 = 100;
- float pf1 = 2.5, pf2 = 1.5;
- troca_int( &int1, &int2);
- troca_float( &pf1, &pf2);
- printf( "Int1: %i, int2: %i, pf1: %f, pf2: %f\n\n", int1, int2, pf1, pf2);
- system( "PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement