Ex: Ziffernsturz

#include <iostream>
#include <conio.h>
 
using namespace std;
 
int main()
{int zahl,help;
 cout<<"Das folgende Programm invertiert die Ziffern einer Zahl.";
 cout<<"\n Geben Sie eine natuerliche Zahl ein: ";
 
 cin>>zahl;
 help = zahl;
 
 do {	
   cout << help%10; 
   help  = help/10; 
 } while(help>0);
 
 getch();
 return 0;
}

Ex: Summe

#include <iostream>
#include <conio.h>
using namespace std;
 
int main()
{
int i,n,sum=0;
cout<< "Das folgende Programm summiert die Zahlen 1 - n auf. \n";
cout<<"Geben Sie eine Obergrenze ein: ";
cin>>n;
 
for (i=1;i<=n;i++) {
  sum=sum+i;  
}    
 
cout << "Ergebnis: " << sum;
getch();
return 0;
}