fork download
  1. #include <stdio.h>
  2. //練習問題A
  3.  
  4. static int func(int n){
  5. if(n<0){
  6. return n*(-1);
  7. }
  8. else{
  9. return n;
  10. }
  11. }
  12.  
  13. int main(void) {
  14. int n, m = -3;
  15. n = func(m);
  16. printf("%dの絶対値は%d\n", m,n);
  17. return 0;
  18. }
  19.  
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout
-3の絶対値は3