Showing posts with label sum. Show all posts
Showing posts with label sum. Show all posts

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


C++ BLACKJACK

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