'Can't run my c program and there are no errors
When I try to compile my code it does not run the command prompt but when I use the VSC it does run, my other c programs run but idk why this one doesn't, and it doesn't have any error when I compile, it just appears to finish the program but it doesn't show anything, pls help I want to know why so I can learn.
#include <stdio.h>
int main()
{
const double mercury = 0.38;
const double venus = 0.91;
const double mars = 0.38;
const double jupiter = 2.34;
const double saturn = 1.06;
const double uranus = 0.92;
const double neptune = 1.19;
double weight;
int x;
// Ask for the current weight on earth
printf("\nEnter your current weight on earth: \n");
scanf("%lf", &weight);
// Show the options
printf("\nThis are the planets in the solar system that you can go to: \n");
printf("\n1.mercurty | 2.venus | 3.mars | 4.jupiter | 5.saturn | 6.uranus | 7.neptune \n");
// Ask for the planet they want to go
printf("\nEnter the number of the planet you would like to visit: \n");
scanf("%d", &x);
// calculate the weight
if (x == 1)
{
weight *= mercury;
}
else if (x == 2)
{
weight *= venus;
}
else if (x == 3)
{
weight *= mars;
}
else if (x == 4)
{
weight *= jupiter;
}
else if (x == 5)
{
weight *= saturn;
}
else if (x == 6)
{
weight *= uranus;
}
else if (x == 7)
{
weight *= neptune;
}
else
{
printf("are you dumb or what? Select a number that appears in the options. \n");
}
// Print the weight
printf("\nYou've selected the planet number: %d\n", x);
printf("your weight will be: %f kg\n", weight);
return 0;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
