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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:01:09+00:00 2026-05-31T02:01:09+00:00

Please help me, i’m stuck at this. I have a function which must sum

  • 0

Please help me, i’m stuck at this.
I have a function which must sum two arrays of integers of size n
and i must pass as arguments for the function the first element of each array
Is this enven close?

 12 void sumVect(int * v[], int * w[] ,int n)
 13 //adds the second vector to the first vector; the vectors v and w have exactly n components
 14 {
 15         int i;
 16         for(i=0;i<n;i++)
 17         {
 18                 *v[i]+=*w[i];
 19         }
 20 
 21 }

I will give you the whole code

#include <stdio.h>

void sumVect(int * v[], int * w[] ,int n)
//adds the second vector to the first vector; the vectors v and w have exactly n components
{
    int i;
    for(i=0;i<n;i++)
    {
        *v[i]+=*w[i];
    }

}


int main()
{   
    int i,j;
    int n = 4;  //the size of a vector
    int k = 5;  //the number of vectors
    int v[k][n];    //the vector of vectors

    printf("How many vectors? k=");
    scanf("%d",&k);

    printf("How many components for each vector? n=");
    scanf("%d",&n);

    for(i=1;i<=k;i++)   //read the content of each vector from the screen
    {
        printf("\nv%d   |\n_____|\n",i);

        for(j=0;j<n;j++)
        {
            printf("v%d[%d]=",i,j);
            scanf("%d", &v[i][j]);
        }
    }

    for(j=1;j<k;j++)
    {
        sumVect(&v[j], &v[j+1], n);
        for(i=0;i<n;i++)
        {
            printf("%d",v[j][i]);
        }
    }


    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-05-31T02:01:11+00:00Added an answer on May 31, 2026 at 2:01 am

    Note that you are passing type int [] but your formal parameters in the function is int *[] . Therefore your signature should be:

    void sumVect(int v[], int w[] ,int n)

    or

    void sumVect(int *v, int *w,int n)

    Also you should access them in the function like

    v[i] + w[i] because v and w both are int * or int [] (depends on the formal paremeter)

    Also when calling you should do:

    sumVect(v[j], v[j+1], n);

    or

    sumVect(&v[j], &v[j+1], n);

    This is because as as v[j] is type of int [] , &v[i] and v[i] will evaluate to the same address.

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

Sidebar

Related Questions

please help me understand this. You have a function that calls a few methods:
please help on this issue: Within a loop, I first call a function, which
Please help me to solve this: I have two strings for email-id and password
Please help! Background info I have a WPF application which accesses a SQL Server
Please Help me to do this first i have this div <div class=loader alt=stat.php>
Please help me understand the meaning of this code. I have seen this kind
please help me with this, i two tables named tblaccess(nID,nRoleID,nModuleID,cAccess) and tblmodule(nModuleID,cModuleName) and i
please help me solve this issue. I have a client using WCF. I don't
Please help me clear this concept. Say we have A socket port server implemented
Please help me: I have two columns in mysql table - date1 (datetime) and

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.