Thread: Spliting one array in two arrays

  1. #1
    Registered User
    Join Date
    Dec 2015
    Posts
    29

    Spliting one array in two arrays

    Hi everyone i made program for spliting one array but it doesn't work
    Code:
    #include <stdio.h>
    void split();
    {
    int a[50], b[50], c[100],n;
    }
    main()
    {
    int i;
    printf("\nEnter size of C: ");
    scanf("%d", &n);
    printf("\nEnter elements of C:\n");
    for(i=0; i<n; i++)
    {
    scanf("%d", &c[i]);
    }
    split();
    printf("\nNew array A is:\n");
    for(i=0; i<n; i++)
    {
    printf("\n%d", a[i]);
    }
    printf("\nNew array B is:\n");
    for(i=0; i<n; i++)
    {
    printf("\n%d", b[i]);
    }
    }
    void split()
    {
    int i;
    for(i=0; i<n; i+2)
    {
    a[i] = c[i];
    }
    for(i=1;i<n;i+2)
    {
    b[i]=c[i];
    }
    }
    I want to split on this way: а = c0, c2, c4, , c2N-2 , b = c1, c3, c5, ,c2N-1

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,163
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Dec 2015
    Posts
    29
    There is only 39 lines of code and you can't understand ?!

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,163
    There are only 39 lines of code and you can't be bothered to indent it?

    If that's your current attitude, forget about a career in software development.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Dec 2015
    Posts
    29
    Don't tell me about career, if you can help help me or leave this post.

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,911
    Start by indenting your code properly. As you do so, one mistake might become more obvious.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,163
    Good luck getting help if that's your attitude.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. spliting strings
    By tyroiusrtmaonm in forum C++ Programming
    Replies: 8
    Last Post: 07-08-2007, 12:21 AM
  2. Spliting among 2 files
    By Suchy in forum C++ Programming
    Replies: 6
    Last Post: 11-09-2006, 03:34 AM
  3. Spliting strings?
    By bladerunner627 in forum C++ Programming
    Replies: 19
    Last Post: 09-28-2005, 02:45 PM
  4. Cin auto spliting why?
    By bladerunner627 in forum C++ Programming
    Replies: 4
    Last Post: 09-25-2005, 05:38 PM
  5. Spliting the bytes
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 06-05-2002, 01:12 AM

Tags for this Thread