1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

c program

Discussion in 'C' started by gurpreet guppi, Oct 19, 2011.

  1. gurpreet guppi

    gurpreet guppi New Member

    Joined:
    Oct 19, 2011
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    hi, i am student of bca i want to make a program in c whose output will as
    *******
    * *
    * *
    * *
    * *
    *******
    please tell me what will be the logic.help me
     
  2. DRK

    DRK New Member

    Joined:
    Apr 13, 2012
    Messages:
    44
    Likes Received:
    3
    Trophy Points:
    0
    Code:
    printf("*******\n");
    printf("* *\n");
    printf("* *\n");
    printf("* *\n");
    printf("* *\n");
    printf("*******\n");
     
  3. gurpreet guppi

    gurpreet guppi New Member

    Joined:
    Oct 19, 2011
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    sorry but using for loop
     
  4. vinay singh

    vinay singh New Member

    Joined:
    Nov 6, 2011
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    
    int m,n;
    for(m=1;m<8;m++)
    {
    printf("* ");
    } 
    printf("%c",10);
    for(m=1;m<5;,m++)
    {
    for(n=1;n>3;n++)
    {
    printf("* ");
    }
    printf("\n");
    }
    for(m=1;m<8;m++)
    {
    printf("* ");
    }
    }
     
  5. vinay singh

    vinay singh New Member

    Joined:
    Nov 6, 2011
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    write a program to print the fibonacci series
    0,1,1,2,3,5,8,13,21
     
  6. vinay singh

    vinay singh New Member

    Joined:
    Nov 6, 2011
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    now i am studying about the strings but now i am unable to understand the string functions as strcpy,strcat,strcmp,strlen so please give me full detailment of them with the suitable examples
     
  7. vinay singh

    vinay singh New Member

    Joined:
    Nov 6, 2011
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    you can make this program by string also if you want by string i will make it please tell me
     
  8. vinay singh

    vinay singh New Member

    Joined:
    Nov 6, 2011
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    hi good evening friends this question i am posting for all the novices .
    write a program that will read a set of the real numbers and find the maximum and the minimum number entered.
     
  9. hobbyist

    hobbyist New Member

    Joined:
    Jan 7, 2012
    Messages:
    141
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    outer_loop(0 < max_row) {
       inner_loop(0 < max_col) {
          if(outer_loop iterator is 0 or max_row - 1)
             // output a single '*'
          else if(inner_loop iterator is 0 or max_col - 1)
             // output a single '*'
          else 
             // output a single space
       }
    
       // output a single newline
    }
    you could probably condense the else/if line with the if line using an || test.

    Code:
    if((outer_loop iterator is 0 or max_row - 1) || (inner_loop iterator is 0 or max_col - 1))
       // output a single '*'
    
    it's been a while since I've coded anything, but maybe something like that.

    HTH
     

Share This Page