Stefans Wiki



Grundrechenarten

main.cpp

 1: /**
 2:  * Projekt: Grundrechenarten
 3:  *
 4:  * @author Stefan Jahn
 5:  * @version 20070316
 6:  * @date 16.03.2007
 7:  *
 8:  * @file main.cpp
 9:  */
10:
11: #include <iostream>
12: using namespace std;
13:
14: /**
15:  * main-Funktion
16:  */
17: int main (int argc, char const *argv[]) {
18:     cout << "Grundrechenarten:" << endl;
19:     cout << "=================" << endl;
20:
21:     // Variabeln
22:     int a = 10;
23:     int b = 7;
24:     float c = 0;
25:
26:     cout << "Werte:" << endl;
27:     cout << "a = " << a << endl;
28:     cout << "b = " << b << endl;
29:     cout << endl;
30:
31:     cout << "Rechnungen:" << endl;
32:
33:     // Addition
34:     c = a+b;
35:     cout << "c = a+b = " << c << endl;
36:
37:     // Subtraktion
38:     c = a-b;
39:     cout << "c = a-b = " << c << endl;
40:
41:     // Multiplikation
42:     c = a*b;
43:     cout << "c = a*b = " << c << endl;
44:
45:     // Division
46:     c = (float)a/b;
47:     cout << "c = a/b = " << c << endl;
48:
49:     // Modulo
50:     c = a%b;
51:     cout << "c = a%b = " << c << " (Ganzahlige Divison a/b und davon der Rest zu a)" << endl;
52:
53:     cout << endl;
54:     cout << "Inkrement und Dekrement:" << endl;
55:
56:     // Dekrement
57:     c = 10;
58:     c--;
59:     cout << "c = 10, c--, c = " << c << endl;
60:
61:     // Inkrement
62:     c = 10;
63:     c++;
64:     cout << "c = 10, c++, c = " << c << endl;
65:
66:     // Rechenoperation direkt mit einer Variabel
67:     cout << endl;
68:     cout << "Rechenoperation direkt mit einer Variabel:" << endl;
69:
70:     // Addition
71:     a = 10;
72:     a += 5;
73:     cout << "a += 5, a = " << a << endl;
74:
75:     // Subtraktion
76:     a = 10;
77:     a -= 5;
78:     cout << "a -= 5, a = " << a << endl;
79:
80:     // Multiplikation
81:     a = 10;
82:     a *= 5;
83:     cout << "a *= 5, a = " << a << endl;
84:
85:     // Division
86:     a = 10;
87:     a /= 5;
88:     cout << "a /= 5, a = " << a << endl;
89:
90:     return 0;
91: }
cpp/kurzerklaerungen_und_grundlagen/grundrechenarten.txt · Zuletzt geändert: 12.07.2011 12:12 (Externe Bearbeitung)
Quelle: http://stefanjahn.de/cpp:kurzerklaerungen_und_grundlagen:grundrechenarten?s%5B%5D=using
Webseite: http://stefanjahn.de