fork download
  1. // C code
  2.  
  3. // This program will result the dollar amount of a tip given of a positive float
  4. //input by a user.
  5. // Developer: BJ Tate
  6. // Date: 26 February 2017
  7.  
  8. #include <stdio.h>
  9.  
  10. // function prototypes
  11. float tips(int);
  12.  
  13. int main (void)
  14. {
  15. /* variable definition: */
  16. int intValue;
  17. float tips:
  18.  
  19. {
  20. printf("Enter a dollar amount to see the resulting 15 percent tips:\n:");
  21. scanf("%d", &intValue);
  22. // if a positive number
  23. if (intValue > 0)
  24. }
  25. tips = Tip(intValue);
  26. printf("A 15 percent tips of %d would be: %f\n", intValue, tips);
  27. }
  28. return 0;
  29. }
  30. /* function return is 15 percent tips of an equilateral triangle */
  31. float tip(intValue)
  32. {
  33. float returnValue;
  34. returnValue = intValue + (intValue*0.15);
  35. return returnValue;
  36. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
10
compilation info
prog.c: In function ‘main’:
prog.c:17:12: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘:’ token
  float tips:
            ^
prog.c:17:12: error: expected expression before ‘:’ token
prog.c:26:46: warning: format ‘%f’ expects argument of type ‘double’, but argument 3 has type ‘float (*)(int)’ [-Wformat=]
   printf("A 15 percent tips of %d would be: %f\n", intValue, tips);
                                              ^
prog.c: At top level:
prog.c:28:1: error: expected identifier or ‘(’ before ‘return’
 return 0;
 ^~~~~~
prog.c:29:1: error: expected identifier or ‘(’ before ‘}’ token
 }
 ^
prog.c: In function ‘tip’:
prog.c:31:8: warning: type of ‘intValue’ defaults to ‘int’ [-Wimplicit-int]
  float tip(intValue)
        ^~~
stdout
Standard output is empty