Some simple C related questions

Discussion in 'Programming' started by dura_killer, Sep 29, 2008.

  1. #1
    I have few C related questions.Someone having knowledge of C plz answer these.


    1..What is the use of fflush(stdin) in this program?

    scanf("%d%d",&a,&b);
    fflush(stdin)
    scanf("%c",&ch);
    
    Code (markup):
    Also what is buffer exactly as it is associated with fflush often?

    2..I need algorithms to print following 2 patterns but in different programs.

    5
    44
    333
    2222
    11111
    Code (markup):
    
    5
    54
    543
    5432
    54321
    Code (markup):


    Someone give answers to these, would be really appreciated.
     
    dura_killer, Sep 29, 2008 IP
  2. Will.Spencer

    Will.Spencer NetBuilder

    Messages:
    14,789
    Likes Received:
    1,040
    Best Answers:
    0
    Trophy Points:
    375
    #2
    In the long run, none of us would be doing you a favor if we did your school work for you.
     
    Will.Spencer, Sep 29, 2008 IP
  3. dura_killer

    dura_killer Peon

    Messages:
    684
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I have exam in 6 hrs otherwise I wouldn't be posting here. :D
     
    dura_killer, Sep 29, 2008 IP
  4. einsteinsboi

    einsteinsboi Well-Known Member

    Messages:
    1,122
    Likes Received:
    76
    Best Answers:
    0
    Trophy Points:
    140
    #4
    What he said :), looks like homework to me. Any C textbook should have the answers for you. Or you can ask mighty G.
     
    einsteinsboi, Sep 29, 2008 IP
  5. javaongsan

    javaongsan Well-Known Member

    Messages:
    1,054
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #5
    a little rust in c
    For (i=5;i<0;i--)
     y=i	
     FOR (X=i; X>6; X++)
       y=y&i
    
    
    For (i=5;i<0;i--)
     y=i	
     FOR (X=i; X>6; X++)
       y=y&(i-1)
    
    Code (markup):
     
    javaongsan, Sep 29, 2008 IP