Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9198399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:16:22+00:00 2026-06-17T22:16:22+00:00

I have to write a program that creates an array and then counts the

  • 0

I have to write a program that creates an array and then counts the total number of possible additions that can be made between the elements. (It doesn’t matter what is actually in the element just how many combinations can be made). i.e a 2*2 array should have 10 possible additions. So far my code looks like

#include <iostream>
#include <ctime>
#include <stdlib.h>
#include <vector>
using namespace std;

int n;
int count;

int main()
{
cout<<"\nEnter Number of rows and columns you wish to calculate the 
possible number additions. \n;            
cin >> n;
if (!cin)
{
    do
    {
    n = 0;
    cout << "That is not a valid number, please enter another. \n";
    cin >> n;
    }
    while (!cin);
}

vector<vector<int> > matrix(n);
for ( int i = 0 ; i < n ; i++ )
{
matrix[i].resize(n);
}


for(int i =1; i < n^2; ++i)
{   
    count = count + i;
}

cout << count;

return (0);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:16:23+00:00Added an answer on June 17, 2026 at 10:16 pm

    Could you try and explain exactly what you’re trying to do? what do you mean “counts the total number of possible additions that can be made between the elements”? why do you need to create an array if the answer is independent on the actual elements (otherwise I don’t understand your 2*2 example).

    One problem that I can spot in your code is that you mistake n^2 to be equal to n*n but the ‘^’ operator is actually a XOR bit-wise operator.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to write a program that sniffs network packets (part1-the simple part). And
I have to write a Java program that tells what coins to give out
I have to write a daemon program that constantly runs in the background and
I wanted to write a program that test if two files are duplicates (have
I have been assigned wit the task to write a program that takes a
I have a program that looks like this. I need to consistently write something
I have a robot that I need to write an autonomous program for. The
I have an assignment to Write a C program that allows a user to
I am tryimg to write a C program that will search an array of
I have to write a program that takes an Integer and converts it into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.