Skip to content
Snippets Groups Projects
Commit df3a5a68 authored by bartvbl's avatar bartvbl
Browse files

Added handout for lecture 9

parent ecc67536
No related branches found
No related tags found
No related merge requests found
#include <vector>
#include <iostream>
//------------------------------------------------------------------------------'
// Eksempel fra gjesteforelesning 18.03.25
// Skop
double finnRabatt(double p) {
return 0.1 * p;
}
int main() {
std::vector<double> priser {50, 10};
double totalRabatt = 0;
for (int i = 0; i < priser.size(); i++) {
double pris = priser.at(i);
if (pris > 20) {
totalRabatt += finnRabatt(pris);
}
}
std::string melding = "Rabatt på varen er: ";
if (priser.size() > 1){
std::string melding = "Rabatt på varene er: ";
std::cout << "Vi har flere varer." << std::endl;
std::cout << melding << std::endl;
}
std::cout << melding << totalRabatt << std::endl;
return 0;
}
//------------------------------------------------------------------------------
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment