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