Home » questions » i need help in c++ programming...?

i need help in c++ programming...?

2006-08-09 03:16:11, Category: Programming & Design
i need to make a program that will scan the number n and then output the sum of the squares from 1 to n. thus, if the input is 4, the output should be 30 because: 1²+2²+3²+4² 1 + 4 + 9+ 16 =30 hope anyone there can help me with this....

Answers

  1. Nikhil G

    On 2006-08-09 03:22:16


    int sum_n2(int n[20],int size) { int i=0; int sum=0; for (i=0;i
  2. Samvit

    On 2006-08-09 03:23:55


    #include....... .............. { int n; float sum; cout<<"Enter a number : "; cin>>n; sum=(n*(n+1)*((2*n)+1))/6; cout<
  3. k_saravappa81

    On 2006-08-09 03:45:39


    #include class square { int n; long int sumofsquaresofN; public: void Read(); void calculate(); }; void square::Read() { cout<<"enter any integer"; cin>>n; } void square:: calculate() { sumofsquaresofN = n*(n+1)*(2*n+1)/6; cout<<"sum of sqares upto n"<