Faldi767

Selisih Kuadrat

Jan 22nd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6.  
  7. /*
  8.  * File:   main.cpp
  9.  * Author: FALDI
  10.  *
  11.  * Created on January 22, 2017, 7:16 PM
  12.  */
  13.  
  14. #include <iostream>
  15.  
  16. using namespace std;
  17.  
  18. /*
  19.  *
  20.  */
  21. int main(int argc, char** argv) {
  22.     int hasilkuadrat, hasiljumlahkuadrat, b;
  23.     for(int a=1;a < 51;a++) {
  24.         b += a;
  25.         hasilkuadrat = hasilkuadrat + (a * a);
  26.         hasiljumlahkuadrat = b * b;
  27.     }
  28.     cout << hasiljumlahkuadrat - hasilkuadrat;
  29.     return 0;
  30. }
Add Comment
Please, Sign In to add comment