limun11

Untitled

Jan 23rd, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. /*
  2. Zadatak 4
  3. Napišite program, koji omogućava unos prirodnog broja n i realnog broja x preko tastature te izračunava sumu:
  4.  
  5. S=sin(x)+sin2(x)+sin3(x)+ …+sinn(x)
  6. */
  7. #include <iostream>
  8. #include <cmath>
  9.  
  10. using namespace std;
  11.  
  12. int main()
  13. {
  14.     int n;
  15.     float x;
  16.     cout << "Prirodan broj: ";
  17.     cin >> n;
  18.     while (n < 0)
  19.     {
  20.         cout << "Broj nije prirodan. ponovi unos: ";
  21.         cin >> n;
  22.     }
  23.     cout << "Realan broj: ";
  24.     cin >> x;
  25.     int s = 0;
  26.     for (int i = 1; i <= n; i++)
  27.     {
  28.         s = sin(i) + x;
  29.     }
  30.     cout << s << endl;
  31.     system("PAUSE");
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment