gpsgiraldi

_2024_@19_02

Oct 12th, 2024
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.39 KB | Source Code | 0 0
  1. /*Exercício 2: Soma de Dois Números
  2. Crie uma função que calcule a soma de dois
  3. números inteiros e armazene o resultado em uma
  4. variável passada por ponteiro.*/
  5. #include <stdio.h>
  6.  
  7. int soma(int a, int b, int *pfun){
  8.     a=a+b;
  9.     *pfun=a;
  10.     return *pfun;
  11. }
  12.  
  13. int main()
  14. {
  15.  
  16.     int x=4,y=2,c;
  17.     int *pmain=&c;
  18.     soma(x,y,pmain);
  19.  
  20.     printf("%d!",c);
  21.  
  22.     return 0;
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment