Monday, September 23, 2019

Write C++ statement that compute the sum of squres of given positive integer

Code


#include <iostream>
using namespace std;
int squaresum(int n) ;


int main()
{
int n;
 cout<<"Enter a positive integer : ";cin>>n;
 cout << squaresum(n) << endl;
 return 0;
}

int squaresum(int n)
{

 int sum = 0;
 for (int i = 1; i <= n; i++)
  sum += (i * i);
 return sum;
}


OUTPUT


1 comment:

  1. Sömbät – kirill - Kohli Kondrashin
    The kirill is the most famous and famous of 카지노 the two popular kirill-kondrashin cultures around the world. In fact, it is the oldest known of all of the animals that holds the

    ReplyDelete

C++ BLACKJACK

#include <iostream> #include <ctime> #include <stdlib.h> #include <time.h> #include <string> using namesp...