Mit Wurzel und Dreieck gibt es hier zwei kleine Codes für Zwischendurch…

Quellcode für den Wurzelrechner:

#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;
}


Quellcode für das Dreieck:

#include <iostream>

int main()
{
int loop1, loop2;

for (loop1 = 1; loop1<= 10; loop1++)
{
for(loop2 = loop1; loop2 > 0; loop2--)
{
std::cout << "x";
}

std::cout << std::endl;
}

return 0;

Von Torsten

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert