Tassos

Άθροισμα των τετραγώνων έως το N.

Apr 2nd, 2014
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.59 KB | None | 0 0
  1. {                              Visit:   http://g-lts.info/  for more code!                       }
  2.  
  3. #include <stdio.h>
  4. #include <math.h> /* για να μπορέσουμε να χρησιμοποιήσουμε την συνάρτηση pow() */
  5.  
  6. int main (void)
  7.  
  8. {
  9.  
  10. long int n,i,t;
  11.  
  12.  
  13. t=0;
  14.  
  15. printf("Δώσε έναν ακέραιο : ");
  16. scanf("%ld",&n);
  17.  
  18. for (i=1; i<=n; i++)
  19.     t += pow(i,2); /*  pow(βάση, εκθέτης);   */
  20.  
  21. printf ("N = %ld\n",t);
  22.  
  23. return 0;
  24. }
  25.  
  26. {                              Visit:   http://g-lts.info/  for more code!                       }
Advertisement
Add Comment
Please, Sign In to add comment