04-19-2024, 07:22 PM
Since I was just writing about C (Aurel), here's the whole stuff also in C++.
Compile with:
PS D:\Lab\C++> g++ -o ausgabe-formatiert ausgabe-formatiert.cpp
Code: (Select All)
//Die formatierte Ausgabe auch noch in C++ - 19. April 2024
//-iomanip- Für setw() und cin.width(int)
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main(void)
{
int eingabe;
system("cls");
cout << "\nThis program will count to 100 from the number you supply.";
cout << "\nEnter the number to start counting from > ";
cin >> eingabe;
cout << "\n";
for(int i = eingabe; i <= 100; i++)
{
//Festpunktzahl - Nachkommastellen - Feldbreite
cout << fixed << setprecision(0) << setw(4) << i;
if((i % 20) == 0)
cout << "\n";
}
//Neue Zeile
cout << endl;
return(0);
}
Compile with:
PS D:\Lab\C++> g++ -o ausgabe-formatiert ausgabe-formatiert.cpp