Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Zadatak 4
- Napišite program, koji omogućava unos prirodnog broja n i realnog broja x preko tastature te izračunava sumu:
- S=sin(x)+sin2(x)+sin3(x)+ …+sinn(x)
- */
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- int n;
- float x;
- cout << "Prirodan broj: ";
- cin >> n;
- while (n < 0)
- {
- cout << "Broj nije prirodan. ponovi unos: ";
- cin >> n;
- }
- cout << "Realan broj: ";
- cin >> x;
- int s = 0;
- for (int i = 1; i <= n; i++)
- {
- s = sin(i) + x;
- }
- cout << s << endl;
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment