Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // ModerneCppProgram.cpp
- //
- #include <iostream> // C++-bibliotek, filendelsen h er tatt bort
- #include <cstring> // C-bibliotek, filendelsen er borte, det er...
- #include <cctype> // ... kommet en c først i navnet
- using namespace std; // bruker standard navnerom
- void finnSum(const int *tabell, int antElementer);
- int *fillTable(int *array);
- int myarray[20];
- int *peker = myarray;
- const int antElementer = 20;
- int main() {
- int *newarray = fillTable(peker);
- finnSum(newarray,antElementer);
- system("pause"); // Pauser så man kan se output
- return 0; // nødvendig pga at main() er av typen int
- }
- void finnSum(const int *tabell, int antElementer){
- for (int i = 0; i < antElementer-1; i=i+2) {
- cout << tabell[i] << " + " << tabell[i+1] << " = " << tabell[i]+tabell[i+1] << endl;
- }
- }
- int *fillTable(int *tarray){
- for (int i = 0; i < sizeof(tarray)-1; i++) {
- tarray[i] = i;
- }
- return tarray;
- }
Add Comment
Please, Sign In to add comment