C++,
pasted
on Oct 25:
|
// Aufgabe 3.6
#include <iostream>
using namespace std;
int summe(int z1, int z2, int z3, int sum)
{
return sum = z1 + z2 + z3;
}
double produkt(double p1, double p2, double p3, double p4, double p5, double prod)
{
prod = p1 * p2 * p3 * p4 * p5;
return prod;
}
void trennlinie ()
{
cout << endl << "--------------------------------------------------" << endl;
}
int main()
{
int z1, z2, z3, sum;
double p1, p2, p3, p4, p5, prod;
// Summe
cout << "Bitte geben Sie 3 ganze Zahlen ein: " << endl << endl;
cout << "Zahl 1: ";
cin >> z1;
cout << "Zahl 2: ";
cin >> z2;
cout << "Zahl 3: ";
cin >> z3;
cout << endl;
sum = z1 + z2 + z3;
cout << "Die Summe der Eingabe lautet: " << sum << endl << endl;
cout << "Folgende Werte wurden eingegeben: " << z1 << ", " << z2 << ", " << z3 << " ";
cout << endl;
trennlinie(); cout << endl;
// Produkt
cout << "Bitte geben Sie 5 Gleitpunktzahlen ein: " << endl << endl;
cout << "Zahl 1: ";
cin >> p1;
cout << "Zahl 2: ";
cin >> p2;
cout << "Zahl 3: ";
cin >> p3;
cout << "Zahl 4: ";
cin >> p4;
cout << "Zahl 5: ";
cin >> p5;
cout << endl;
prod = p1 * p2 * p3 * p4 * p5;
cout << "Das Produkt der Eingabe lautet: " << prod << endl << endl;
cout << "Folgende Werte wurden eingegeben: " << p1 << ", " << p2 << ", " << p3 << ", " << p4 << ", " << p5 << ", ";
cout << endl << endl;
return 0;
}
|
Output:
|
Bitte geben Sie 3 ganze Zahlen ein:
Zahl 1: Zahl 2: Zahl 3:
Die Summe der Eingabe lautet: -812617683
Folgende Werte wurden eingegeben: 134540864, 134541013, -1081699560
--------------------------------------------------
Bitte geben Sie 5 Gleitpunktzahlen ein:
Zahl 1: Zahl 2: Zahl 3: Zahl 4: Zahl 5:
Das Produkt der Eingabe lautet: inf
Folgende Werte wurden eingegeben: -8.91496e+303, 2.16805, 2.16687, 4.89329e-270, -8.91495e+303,
|
|