CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Coding Arrays

  1. #1
    Join Date
    Dec 2011
    Posts
    1

    Coding Arrays

    Hey guys, my name is robyn and i am new to this site! i am having a bit of trouble coding arrays in c++. I know the basics an array, but am a little unexperienced when it comes to actually coding them. My teacher assigned us this problem:

    int x[5], y[5], n[5] = {1,2,3,4,5};

    Write a program that creates two new arrays. The first new array will square the elements of the original array. The second new array will be the sum of the corresponding array elements of the first two arrays. Here is what your output should look like:

    Number Square Sum

    1 1 2
    2 4 6
    3 9 12
    4 16 20
    5 25 30



    If anyone can help me out a little, it would be sosoooo appreciated.

    xoxo
    Robyn

    PS. If i get an A on this assignment i wouldn't be opposed to posting some hot pix of me

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Coding Arrays

    Quote Originally Posted by xxrobynxx View Post
    ... i am having a bit of trouble coding arrays in c++.
    ...
    If anyone can help me out a little, it would be sosoooo appreciated.
    There are many people here that are ready to help you. But no one will make your homework for you!
    What problem do you have? Don't you know how to create a simple C++ program?
    Don't you know how to program in C some trivial arithmetic operations like addition and multiplication?
    Victor Nijegorodov

  3. #3
    Join Date
    Dec 2011
    Posts
    2

    Re: Coding Arrays

    for 1st array
    you have to power to 2 element by element and this can be done by loop "for" this easy you just have to figure when to start and stop the loop what will be increased every time

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured