Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > plz help to solve some problem

Reply
Thread Tools

plz help to solve some problem

 
 
Fahad
Guest
Posts: n/a
 
      05-27-2005
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.

 
Reply With Quote
 
 
 
 
Jens.Toerring@physik.fu-berlin.de
Guest
Posts: n/a
 
      05-27-2005
Fahad <(E-Mail Removed)> wrote:
> 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.


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.

> Then "how can i get the value of Sin30 degree".


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

> And how can I draw a Triangle or a rectangle shape.


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 ___ http://www.velocityreviews.com/forums/(E-Mail Removed)-berlin.de
\__________________________ http://www.toerring.de
 
Reply With Quote
 
 
 
 
Malcolm
Guest
Posts: n/a
 
      05-27-2005

"Fahad" <(E-Mail Removed)> wrote
>.
> 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.
>

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++;
}
}
>
> Then "how can i get the value of Sin30 degree".
>

double degtorad(double degrees)
{
return degrees/360 * 2 * 3.14;
}

/* get sine 30 degrees */
sin( degtorad(30) );
>
> And how can I draw a Triangle or a rectangle shape.
>

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.


 
Reply With Quote
 
Malcolm
Guest
Posts: n/a
 
      05-27-2005

"Malcolm" <(E-Mail Removed)> wrote in message
news:d785uj$ig3$(E-Mail Removed)-infra.bt.com...
>
> "Fahad" <(E-Mail Removed)> wrote
>>.
>> 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.
>>

> void capitalisewords(char *str)
> {
> char *ptr;
> if(isalpha(*str))
> *str = toupper(*str);
> ptr = str;
> while(ptr = strchr(ptr, ' '))
> {

ptr++;
> if(isalpha(*ptr))
> *ptr = toupper(*ptr);

/* > ptr++; */
> }
> }
>>
>> Then "how can i get the value of Sin30 degree".
>>

> double degtorad(double degrees)
> {
> return degrees/360 * 2 * 3.14;
> }
>
> /* get sine 30 degrees */
> sin( degtorad(30) );
>>
>> And how can I draw a Triangle or a rectangle shape.
>>

> 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.
>



 
Reply With Quote
 
Martijn
Guest
Posts: n/a
 
      05-28-2005
>> void capitalisewords(char *str)
>> {
>> char *ptr;
>> if(isalpha(*str))
>> *str = toupper(*str);
>> ptr = str;
>> while(ptr = strchr(ptr, ' '))
>> {
>> ptr++;
>> if(isalpha(*ptr))
>> *ptr = toupper(*ptr);
>> }
>> }


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
http://www.sereneconcepts.nl


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
plz help me ,, i need some codes ,,plz enter nocturnal VHDL 1 07-10-2009 07:43 AM
req:can some 1 plz get just my luck in here plz thankx u this is my1st post Rollson Computer Support 1 06-19-2006 08:47 PM
plz help to solve some problem Fahad C Programming 16 06-05-2005 03:28 AM
Re: plz help!!! plz plz plz plzplzplz help the noob alkzy Microsoft Certification 0 10-31-2004 10:04 PM
Computer Problems... Plz Plz Plz HELP ME..... Nick Computer Support 0 06-04-2004 08:50 PM



Advertisments