fork download
  1. /// C code
  2. // This program will calculate the Perimeter of a right triangle.
  3. // Developer: Faculty CMIS102
  4. // Date: Jan 31, XXXX
  5.  
  6. #include <stdio.h>
  7.  
  8. int main ()
  9. {
  10. /* variable definition: */
  11. float base, sidea, sideb, perimeter;
  12.  
  13. /* Prompt user for base */
  14. printf("Enter the base of the triangle: \n");
  15.  
  16. // Input the base
  17. scanf("%f", &base);
  18.  
  19. /* Prompt user for sidea */
  20. printf("Enter the sidea of the triangle: \n");
  21.  
  22. // Input the sidea
  23. scanf("%f", &sidea);
  24.  
  25. /* Prompt the user for sideb */
  26. printf("Enter the sideb of the triangle: \n");
  27.  
  28. //Input the sideb
  29. scanf("%f", sideb)
  30.  
  31. //Calculate the Perimeter
  32. Perimeter= (base + sidea + sideb);
  33.  
  34. // Print the result
  35. printf("Perimeter is : %f\n", perimeter);
  36.  
  37. return 0;
  38. }
  39.  
  40.  
  41.  
Compilation error #stdin compilation error #stdout 0s 9432KB
stdin
5
10
5
compilation info
prog.c: In function ‘main’:
prog.c:29:11: warning: format ‘%f’ expects argument of type ‘float *’, but argument 2 has type ‘double’ [-Wformat=]
   scanf("%f", sideb)
           ^
prog.c:32:3: error: expected ‘;’ before ‘Perimeter’
   Perimeter= (base + sidea + sideb);
   ^~~~~~~~~
stdout
Standard output is empty