I know you're usually not meant to put out all of your code but this is short and would help with the problem. Can anyone please explain why the output is 0 and how I can change the code to output what should be the volume of a cone.
#include <stdio.h> float ConeVolume(int height, int radius); float ConeVolume(int height, int radius) { float pi; pi = 3.14159; float third; third = (1/3); float vol; vol = third * pi * radius * radius * height; return vol; } int main() { float x = ConeVolume(12,10); printf("%.4f \n", x); } edit: thank you to all who answered so quickly. Great community here.
gcc -Wall -Wextra -g). Then use the debugger (gdb) by single stepping your program. You would have found your bug quickly (faster than asking here).