0

Hi guys hope you doing fine, so i am new at C programming with eclipse. The problem is in working with eclipse is that it's not showing outputs. Hope guys you can help me and thank you. here's the code:

#include <stdio.h>
    int main()
    {
float result;
int choice;
printf("Press 1 to calculate area of circle\n");
printf("Press 2 to calculate area of square\n");
printf("Press 3 to calculate area of sphere\n");
printf("Enter your choice:\n");
scanf("%d",&choice);

switch (choice) {
case 1: {
    printf("Enter radius:\n");
    result = 3.14 * 4;
    printf("Area of sphere=%f",result);
    break;
}
case 2: {
    printf("Enter side of square:\n");
    result = 4;
    printf("Area of square=%f",result);
    break;
}
case 3: {
    printf("Enter radius:\n");
    result = 4 * (3.14 * 4);
    printf("Area of sphere=%f",result);
    break;
}
default:
    printf("wrong Input\n");
}
return 0;
}
  • 1
    Eclipse's console doesn't necessarily flush the way you might expect. But the program might also be crashing before it gets a chance to output anything. I recommend adding code to the question so we have a shot at explaining what the problem is. – user4581301 Dec 01 '21 at 20:17
  • 1
    I find that with Eclipse, I have to put a `fflush(stdout);` after each `printf` call to get the output to show up in the console. – Fred Larson Dec 01 '21 at 20:27

0 Answers0