Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- /*
- Napisite program, postujuci sve faze procesa programiranja, koji omogucava unos broja n preko tastature
- te izracunava sumu:
- S=1/3^2 + 1/5^2 + ... + 1/(2n+1)^2
- Upotrijebite funkciju: float suma (int);
- */
- float suma(int n){
- float suma = 0;
- for (int i = 1; i <= n; i++){
- if (i % 2 != 0){
- suma += 1 / pow(i, 2);
- }
- }
- return suma;
- }
- void main(){
- int n;
- cout << "Unesite prirodni broj n: " << endl;
- cin >> n;
- cout << "Suma iznosi: " << suma(n) << endl;
- system("pause>0");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement