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 8579391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:36:01+00:00 2026-06-11T20:36:01+00:00

So my program makes a random (x,y) arrays, what i want to do is

  • 0

So my program makes a random (x,y) arrays, what i want to do is to make x a real number and y imaginary number and add them:
my main program

    #include "complx.h"                          
    int main(){
    const int n = 2;
    Complex a[n];                          
    getData(a,n);
    printArray(a,n);
    isort(a,n);
    printArray(a,n);
    complex_sum(a,n);
    return 0;
}

it also prints and arranges the arrays, but what I am interested in is how to add the arrays, when for example I would use 4 arrays (x,y)(x,y)(x,y)(x,y).

this is how i get a random numbers

    void getData(Complex a[],int n){
    int  i;
    srand(time(0)); //If comment this out, get same sequence with each run.      
    for(i=0; i<n; i++){
        a[i].x = rand()%3;  //3 and 10 are just for testing isort                
        a[i].y = rand()%10;
    }
    return;
}

and here is how i’m trying to add it:

void complex_sum(Complex a[], int n){
    for (int i=0; i<n; i++)
      cout<<"("<<a[i].x+a[i].x<<")";
    cout<<endl;
    return;

I am stuck on how to add (x,y)(x,y)= x+yi

thanks

  • 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-11T20:36:02+00:00Added an answer on June 11, 2026 at 8:36 pm

    I am not completely inline with the way you are attempting; but to sum n number of complex numbers stored in an array and print it on screen you can try the following:

    void complex_sum(Complex a[], int n){
        int real=0,img=0;
        for (int i=0; i<n; i++){
            real+=a[i].x;
            img+=a[i].y;
        }
        cout<<"("<<real << "+" << img << "i)";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make a simple program that sends random keystrokes to my other
I have a GridView with 16 ImageView buttons. My program makes a random number
my program makes a random name that could have a-z this code makes a
Possible Duplicate: Java: generating random number in a range I want to generate a
im trying to make facebook upload photo with random tag friend. the program was
I am developing a program in which I need to generate a random number
#include<iostream> #include<string> using namespace std; int main(void) { struct STRCT { int num; string
I have a program that makes use of the following method to get a
I'm developing a program that makes some floating points calculations. Is there any way
I'm developing a simple program which makes a Python script executable, and I'm working

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.