I'm new to programming I'm about to write my first programs. I successfully installed VS Code and MinGW 64 on my Windows 10 system.
My program is compiling and the scanf
is recognised by the compiler. The problem is that it gives 0
as an output for the variable. The code has German comments because of my German background. Please bear with me, I'm new to programming.
The code is as follows:
#include <stdio.h>
int main()
{
const double PI = 3.14159; // Kreiskonstante pi
double r = 0.0; // Radius der Kugel
double A = 0.0; // Oberfläche der Kugel
double V = 0.0;
// Radius vom Benutzer einlesen
printf("Kugelradius: ");
scanf("%.2lf", &r);
// Oberfläche berechnen
A = 4.0 * PI * r * r;
// Hier Code zur Volumenberechnung angeben
V = (4.0 / 3.0) * r * r * r * PI;
// Ausgabe des Ergebnisses
printf("Radius: %.2lf\n", r);
printf("Oberflaeche: %.2lf\n", A);
// hier Code für Ausgabe des Volumens angeben
printf("Volumen: %.2lf\n", V);
}