Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. To take input for n number of arrays and print it.

To take input for n number of arrays and print it.

Scheduled Pinned Locked Moved ATL / WTL / STL
data-structures
10 Posts 3 Posters 24 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tarun Jha
    wrote on last edited by
    #1

    in the below code it prints for arr[0] and not after it. please tell to correct.

    #include int i, j;
    int arr[100][100];

    void array(int arr[i][j], int size[i+1])
    {

    for(j=0; j
    
    L U 2 Replies Last reply
    0
    • T Tarun Jha

      in the below code it prints for arr[0] and not after it. please tell to correct.

      #include int i, j;
      int arr[100][100];

      void array(int arr[i][j], int size[i+1])
      {

      for(j=0; j
      
      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I cannot figure out what you are trying to do but most of what you have makes no sense at all. Statements such as:

      void array(int arr[i][j], int size[i+1]) // what are all these indices supposed to mean?

      scanf("%d", &arr[i][j]);
      printf("arr[%d][%d]\n", i, j); // what are you trying to print?

      T 1 Reply Last reply
      0
      • L Lost User

        I cannot figure out what you are trying to do but most of what you have makes no sense at all. Statements such as:

        void array(int arr[i][j], int size[i+1]) // what are all these indices supposed to mean?

        scanf("%d", &arr[i][j]);
        printf("arr[%d][%d]\n", i, j); // what are you trying to print?

        T Offline
        T Offline
        Tarun Jha
        wrote on last edited by
        #3

        the user will input n number of arrays of different array sizes, and then the program will print every array that user has entered. I want to create a program that will merge n number of arrays.

        L 1 Reply Last reply
        0
        • T Tarun Jha

          the user will input n number of arrays of different array sizes, and then the program will print every array that user has entered. I want to create a program that will merge n number of arrays.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          To create the arrays you need to get the size of each dimension and then create the array dynamically. You cannot pre-allocate them if you do not have their size. Once you have all the requested arrays then you need to create another one that will contain the results of your merge.

          T 1 Reply Last reply
          0
          • L Lost User

            To create the arrays you need to get the size of each dimension and then create the array dynamically. You cannot pre-allocate them if you do not have their size. Once you have all the requested arrays then you need to create another one that will contain the results of your merge.

            T Offline
            T Offline
            Tarun Jha
            wrote on last edited by
            #5

            if you run the code it will take the size of array first and then fill in the respective elements in according to the size entered. But i am not able to print it on the screen. Please run it and tell me what's wrong.

            L 1 Reply Last reply
            0
            • T Tarun Jha

              if you run the code it will take the size of array first and then fill in the respective elements in according to the size entered. But i am not able to print it on the screen. Please run it and tell me what's wrong.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Like I already told you, much of that code makes no sense, so there is no point in me trying to run it. You need to sort out the logic first.

              T 1 Reply Last reply
              0
              • L Lost User

                Like I already told you, much of that code makes no sense, so there is no point in me trying to run it. You need to sort out the logic first.

                T Offline
                T Offline
                Tarun Jha
                wrote on last edited by
                #7

                ok

                1 Reply Last reply
                0
                • T Tarun Jha

                  in the below code it prints for arr[0] and not after it. please tell to correct.

                  #include int i, j;
                  int arr[100][100];

                  void array(int arr[i][j], int size[i+1])
                  {

                  for(j=0; j
                  
                  U Offline
                  U Offline
                  User 13290565
                  wrote on last edited by
                  #8

                  #include

                  void array(int arr[], int i, int size)
                  {
                  for (int j = 0; j

                  T 2 Replies Last reply
                  0
                  • U User 13290565

                    #include

                    void array(int arr[], int i, int size)
                    {
                    for (int j = 0; j

                    T Offline
                    T Offline
                    Tarun Jha
                    wrote on last edited by
                    #9

                    so the problem was = array(arr, size, i) instead of array(&arr[i][0], size, i). Thank you so much :)

                    1 Reply Last reply
                    0
                    • U User 13290565

                      #include

                      void array(int arr[], int i, int size)
                      {
                      for (int j = 0; j

                      T Offline
                      T Offline
                      Tarun Jha
                      wrote on last edited by
                      #10

                      in the code below i have tried using recursion for printing output, but it's not working can you tell me what's wrong.

                      #include int final_array(int arr[], int size, int k, int i);
                      void array(int arr[], int i, int size);

                      int main()
                      {
                      int num, size[100];
                      int i, j, k=0;
                      int arr[100][100];

                      printf("Enter the number of arrays: \\t");
                      scanf("%d", &num);
                      num = num < 100 ? num: 100;
                      //feeding elements.
                      for (i = 0; i
                      
                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups