plz help to solve some problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fahad

    #1

    plz help to solve some problem

    I am a newcommer in c world,
    I am making a tiny program on Mathematics.
    I have one problem if somebody enter his name, "i am able to make the
    first letter uppercase but my problem how can i make the 1st letter
    after space to be uppercase" plz help me.
    Then "how can i get the value of Sin30 degree".
    And how can I draw a Triangle or a rectangle shape.

  • Jens.Toerring@physik.fu-berlin.de

    #2
    Re: plz help to solve some problem

    Fahad <mail2oveek@gma il.com> wrote:[color=blue]
    > I am a newcommer in c world,
    > I am making a tiny program on Mathematics.
    > I have one problem if somebody enter his name, "i am able to make the
    > first letter uppercase but my problem how can i make the 1st letter
    > after space to be uppercase" plz help me.[/color]

    Iterate over the array of chars until you find a space, take the
    next char and covert it to uppercase. If you would show us some
    code you already have we might be able to give you some more
    helpful answer.
    [color=blue]
    > Then "how can i get the value of Sin30 degree".[/color]

    Use the sin() function and call it with an argument of 30 degree
    after you converted that to radians (or simply use 0.5, that
    saves a bit of CPU time;-)
    [color=blue]
    > And how can I draw a Triangle or a rectangle shape.[/color]

    There are no functions in standard C for drawing. You will need
    to use some extensions supplied for the system you are using).
    You will have to ask that in a group that is dedicated to dis-
    cussions about programming for your system.

    Regards, Jens
    --
    \ Jens Thoms Toerring ___ Jens.Toerring@p hysik.fu-berlin.de
    \______________ ____________ http://www.toerring.de

    Comment

    • Malcolm

      #3
      Re: plz help to solve some problem


      "Fahad" <mail2oveek@gma il.com> wrote[color=blue]
      >.
      > I have one problem if somebody enter his name, "i am able to make the
      > first letter uppercase but my problem how can i make the 1st letter
      > after space to be uppercase" plz help me.
      >[/color]
      void capitalisewords (char *str)
      {
      char *ptr;
      if(isalpha(*str ))
      *str = toupper(*str);
      ptr = str;
      while(ptr = strchr(ptr, ' '))
      {
      if(isalpha(*ptr ))
      *ptr = toupper(*ptr);
      ptr++;
      }
      }[color=blue]
      >
      > Then "how can i get the value of Sin30 degree".
      >[/color]
      double degtorad(double degrees)
      {
      return degrees/360 * 2 * 3.14;
      }

      /* get sine 30 degrees */
      sin( degtorad(30) );[color=blue]
      >
      > And how can I draw a Triangle or a rectangle shape.
      >[/color]
      The problem is there is no standard graphical system.

      Drawing lines is surprisingly tricky, and most sytems provide basic line and
      polygon functions as standard. If you really want to know how to do it, look
      up Brasenham's algorithm.
      Once you have a line drawer, an open rectnagle or triangle is no problem.

      Drawing a filled triangle is also tricky. The normal approach is to cut it
      in half so that yiu have a flat-topped and a flat-bottomed triange, and then
      calculate start and end points for each scan line.


      Comment

      • Malcolm

        #4
        Re: plz help to solve some problem


        "Malcolm" <regniztar@btin ternet.com> wrote in message
        news:d785uj$ig3 $2@nwrdmz03.dmz .ncs.ea.ibs-infra.bt.com...[color=blue]
        >
        > "Fahad" <mail2oveek@gma il.com> wrote[color=green]
        >>.
        >> I have one problem if somebody enter his name, "i am able to make the
        >> first letter uppercase but my problem how can i make the 1st letter
        >> after space to be uppercase" plz help me.
        >>[/color]
        > void capitalisewords (char *str)
        > {
        > char *ptr;
        > if(isalpha(*str ))
        > *str = toupper(*str);
        > ptr = str;
        > while(ptr = strchr(ptr, ' '))
        > {[/color]
        ptr++;[color=blue]
        > if(isalpha(*ptr ))
        > *ptr = toupper(*ptr);[/color]
        /* > ptr++; */[color=blue]
        > }
        > }[color=green]
        >>
        >> Then "how can i get the value of Sin30 degree".
        >>[/color]
        > double degtorad(double degrees)
        > {
        > return degrees/360 * 2 * 3.14;
        > }
        >
        > /* get sine 30 degrees */
        > sin( degtorad(30) );[color=green]
        >>
        >> And how can I draw a Triangle or a rectangle shape.
        >>[/color]
        > The problem is there is no standard graphical system.
        >
        > Drawing lines is surprisingly tricky, and most sytems provide basic line
        > and polygon functions as standard. If you really want to know how to do
        > it, look up Brasenham's algorithm.
        > Once you have a line drawer, an open rectnagle or triangle is no problem.
        >
        > Drawing a filled triangle is also tricky. The normal approach is to cut it
        > in half so that yiu have a flat-topped and a flat-bottomed triange, and
        > then calculate start and end points for each scan line.
        >[/color]


        Comment

        • Martijn

          #5
          Re: plz help to solve some problem

          >> void capitalisewords (char *str)[color=blue][color=green]
          >> {
          >> char *ptr;
          >> if(isalpha(*str ))
          >> *str = toupper(*str);
          >> ptr = str;
          >> while(ptr = strchr(ptr, ' '))
          >> {
          >> ptr++;
          >> if(isalpha(*ptr ))
          >> *ptr = toupper(*ptr);
          >> }
          >> }[/color][/color]

          Might as well snug it all in one loop (not using strchr that is) and use
          isblank or isspace instead - this way the function will be more generic (but
          agreed, not up to the users precise spec).

          --
          Martijn



          Comment

          Working...