Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 26th, 2012  |  syntax: C  |  size: 0.60 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. void sum(int a, int b, int *suma);
  4. int main(int argc, char *argv[])
  5. {
  6.   int a, b, suma, k;
  7.   do {
  8.       printf("Podaj a: ");
  9.       k = scanf("%d", &a);
  10.       if(k == 0) printf("Blad formatu!\n");
  11.       fflush(stdin);
  12.   } while(k == 0);
  13.  
  14.   do {
  15.       printf("Podaj b: ");
  16.       k = scanf("%d", &b);
  17.       if(k == 0) printf("Blad formatu!\n");
  18.       fflush(stdin);
  19.   } while(k == 0);
  20.  
  21.   sum(a, b, &suma);
  22.   printf("Suma %d + %d = %d\n", a, b, suma);
  23.   system("PAUSE");     
  24.   return 0;
  25. }
  26.  
  27. void sum(int a, int b, int *suma) {
  28.      *suma = a + b;    
  29. }