need help on array question

This is a discussion on need help on array question within the C Programming forums, part of the General Programming Boards category; Firstly, sorry for my poor coding skill, below code is what i trying right now, i planning to do 3 ...

  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    11

    need help on array question

    Firstly, sorry for my poor coding skill, below code is what i trying right now, i planning to do 3 input for printing line ,after that loop, i wish to have 3 lines printed together which i trying it on second loop. I get stuck how to correct it, anyone can help me on this?


    Code:
    #include <stdio.h>
    int main()
    {
        int value[1000][3],k;
        int loops,value_line;
        
    for(loops=1;loops<=3;loops++)
        {
                
                scanf("%d",&k);
    
    
                if (k==1)
                {
                
                scanf("%d",&value[loops][1]);
                
                printf("\n");
        for(value_line=1;value_line<=value[loops[1];value_line++)
                        printf("* ");                                                
        }
    
    
    
    
        for(int kk=1;kk<=value[loops][0];kk++)
        {
            printf("\n");
        for(value_line=1;value_line<=value[loops][1];value_line++)
            printf("* ");    
        }
        
        printf("\n");
        return 0;
    }
    }
    Last edited by hian3359; 11-26-2012 at 05:31 AM.

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Can you show an example of input you want, and output you want? If you put code tags around it, it will keep the right pattern so I can see it OK.

  3. #3
    Registered User
    Join Date
    Oct 2012
    Posts
    11
    Quote Originally Posted by Adak View Post
    Can you show an example of input you want, and output you want? If you put code tags around it, it will keep the right pattern so I can see it OK.
    what i want is initially i will input first value, and first line printed, after that second then third.after that loop done, i want to see the overall previous 3 line together printed again.

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    user inputs a value (a number?)
    first value is printed out by program

    user inputs second and third value, in a loop
    program prints out all three values that were input by user.

    Is that what you want?

    It looks like maybe you want to print up a diagram of *'s, maybe?

  5. #5
    Registered User
    Join Date
    Oct 2012
    Posts
    11
    Quote Originally Posted by Adak View Post
    user inputs a value (a number?)
    first value is printed out by program

    user inputs second and third value, in a loop
    program prints out all three values that were input by user.

    Is that what you want?

    It looks like maybe you want to print up a diagram of *'s, maybe?
    yes,that is what i want haha, btw sorry for my poor language, haha

  6. #6
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Is k the height in rows of the diagram?

    The shape of the diagram is a pyramid, or a half pyramid, or a diamond shape or a square or what?

  7. #7
    Registered User
    Join Date
    Oct 2012
    Posts
    11
    Quote Originally Posted by Adak View Post
    Is k the height in rows of the diagram?

    The shape of the diagram is a pyramid, or a half pyramid, or a diamond shape or a square or what?
    kk is simply a variable, the main purpose for this is after 3 input(first loop) is completed, second loop is like a summary for that, it will print out all the three input together

  8. #8
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by hian3359 View Post
    kk is simply a variable, the main purpose for this is after 3 input(first loop) is completed, second loop is like a summary for that, it will print out all the three input together
    I'm lost with the shape you want. Show me a simple example of your input and desired output - no descriptions please - just an example.

  9. #9
    Registered User
    Join Date
    Oct 2012
    Posts
    11
    Quote Originally Posted by Adak View Post
    I'm lost with the shape you want. Show me a simple example of your input and desired output - no descriptions please - just an example.
    ok just for example

    first input 3
    print ***
    second 4
    print ****
    third 1
    print *

    then will print

    ***
    ****
    *

  10. #10
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Code:
    #include <stdio.h>
    int main()
    {
        int value[1000][3],k;
        int i;
        
       for(i=0;i<3;i++)
       {
          scanf("%d",&value[0][i]);
    
       }         
       printf("\n");
       for(i=0;i<3;i++)   //for each value input to value[0][i]
       {
          for(k=0;k<???????;k++)  //print one line of *'s
          {
               printf("*");                                                
          }
          printf("\n"); //end of each line
       }
    
      
       printf("\n");
       return 0;
    }
    What would you put in for the stop value for each line. The value[][] array holds these values.

  11. #11
    Registered User
    Join Date
    Oct 2012
    Posts
    11

    Red face

    Quote Originally Posted by Adak View Post
    Code:
    #include <stdio.h>
    int main()
    {
        int value[1000][3],k;
        int i;
        
       for(i=0;i<3;i++)
       {
          scanf("%d",&value[0][i]);
    
       }         
       printf("\n");
       for(i=0;i<3;i++)   //for each value input to value[0][i]
       {
          for(k=0;k<???????;k++)  //print one line of *'s
          {
               printf("*");                                                
          }
          printf("\n"); //end of each line
       }
    
      
       printf("\n");
       return 0;
    }
    What would you put in for the stop value for each line. The value[][] array holds these values.
    i get it dy,thx alot,i got idea for array dy, gonna start my project haha

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Array Question
    By Sorinx in forum C Programming
    Replies: 49
    Last Post: 11-16-2012, 07:07 AM
  2. Replies: 12
    Last Post: 11-21-2010, 08:46 AM
  3. question about the array in C
    By thungmail in forum C Programming
    Replies: 4
    Last Post: 11-07-2009, 12:37 PM
  4. Array Question...
    By tetraflare in forum C++ Programming
    Replies: 6
    Last Post: 11-25-2002, 02:01 PM
  5. array question
    By DocDroopy in forum C Programming
    Replies: 12
    Last Post: 07-28-2002, 06:24 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21