Skip to content
Snippets Groups Projects
cpp_binomial_result.md 1.21 KiB
Newer Older
Nicolas M. Thiéry's avatar
Nicolas M. Thiéry committed
---
jupyter:
  jupytext:
    text_representation:
      extension: .md
      format_name: myst
kernelspec:
  display_name: C++17
  language: C++17
  name: xcpp17
---

### Objectif pédagogique : comprendre une boucle for et faire un calcul simple

```{code-cell} c++
---
editable: false
tags: [hide-cell]
---
#include <iostream>
#include "jupyter_exercizer_helpers.hpp"
using namespace std;
```

+++

```{code-cell} c++
---
tags: [hide-cell, variable]
---
CONST RINIT = RANDOM_INT(1, 7);
RINIT
```

+++

```{code-cell} c++
---
tags: [hide-cell, variable]
---
CONST IMAX = RANDOM_INT(2, 4);
IMAX
```

+++

```{code-cell} c++
---
tags: [hide-output, substitution]
---
int r = RINIT;
int a = 2;
for ( int I = 1; I <= IMAX ; I = I + 1 ) {
    r = r + a * I;
}
```

+++

:::{admonition} Consigne

Quelle est la valeur attendue de `r`?

:::

```{code-cell}
---
editable: true
nbgrader:
  grade: false
  grade_id: init
  locked: false
  schema_version: 3
  solution: true
---
int result = INPUT(
    /// BEGIN SOLUTION
    r
    /// END SOLUTION
);
```

+++

```{code-cell}
---
editable: false
nbgrader:
  grade: true
  grade_id: check
  locked: true
  points: 1
  schema_version: 3
  solution: false
tags: [hide-cell]
---
CHECK( result == r );
```