Jetzt geht es wieder mit C++ weiter. Wie wäre es mal mit einem Programm zur Wurzelberechnung? Dieser Artikel bietet den entsprechenden C++ Code…


C++ Wurzelrechner Version 1:

#include <iostream>
#include <cmath>

int main()
{
double eingabe;
double wurzel;

std::cout << "Programm zur Wurzelberechnung" << std::endl;
std::cout << std::endl;
std::cout << "Geben Sie eine Zahl ein: " ;
std::cin >> eingabe;

if (eingabe >= 0)
{
wurzel = sqrt(eingabe);
std::cout << "Wurzel von " << eingabe << " = "
<< wurzel << std::endl;
}

std::cout << std::endl;
std::cout << "Programm wird beendet. ";
std::cout << std::endl;

return 0;
}

Von Torsten