'C' Programming (CS215)

dal2lad

OSNN Newbie
Joined
22 Oct 2004
Messages
5
'C' Programming HELP

Hi,

Any voluntier to help me in my 'C' Programming ?

The Question:

The fuction below needs to be run in a program.

Write a fuction called ChangeToNext that take in an uppercase character parameter ch. The function returns the next upercase character if ch is between 'A' and 'Y'. If ch =='Z', the function returns 'A'. You may assume that the character parameter ch is always an uppercase alphabetic character.

Thank you
 
That question is very straight forward. If you can't solve it I suggest you read up on what you're supposed to do. I could write it for you, but what good would it do?

At least give it a try. If you can't get it right, post back with what you have and well try to see what's wrong with your code. Good luck! :)
 
This is simple to write. Just a hint:

char blah = 'A';
int num = blah;

prinft ("%d", num);

Should print a number, not the character A. Use this to your advantage, as

char B = (int)A + 1;

So all you really need to check, is if it is Z before you do that, and if it is Z, then set char equal to A.

Damnit, allready gave you to much info. Good luck.
 
/me wants to see the code ;) damn it this is so much like stuff I do in machine code - I love seeeing thing stuff in C and laughing when it is the same # of lines as my assembler (well - nearly!)
 
does this mean you finished the first one? Post it up if you want more help (got to learn step 1 before step 2?)
 
Mainframeguy said:
awwww dear - stragling sounds even worse than struggling ;) :p
Yeah, like strangling. Maybe he got hung in a loop? ;) :D





Oooohh bad one!
 
X-Istence said:
Not everyone knows that off the top of their head :p
quite true, like my Networks and Communications lecturer for example, though it was more odd when he said that lower case started at 41 and upper case started at 61

i mean you can just think about that and know its wrong, theres only 20 characters between 41 and 61, so not enough space. But then he was right about where the upper case started, well close enough :p
 
Geffy said:
quite true, like my Networks and Communications lecturer for example, though it was more odd when he said that lower case started at 41 and upper case started at 61

i mean you can just think about that and know its wrong, theres only 20 characters between 41 and 61, so not enough space. But then he was right about where the upper case started, well close enough :p

First - just off my head I kinow he was right and you are also wrong, you see in HEX the numbers add up fine.....

Second you got it back to front - UPPER case starts at x'41' and LOWER ar x'61'

Sorry to be a smart ass, but I thought I should clear that up, since this is meant to be a "learning" thread ;)
 
FishBoy said:
He doesn't really need ASCII table coz he's only going to work from A to Z which is 65 to 91

Agreed - plus if he starts to embed things like ASCII tables he may actually LOSE points since it will lose cross platform portability, say if it had to compile and run with EBCDIIC instead (where the alpha characters are not even consecutive :eek::)
 
Wouldn't

if chr == 'Z' then
return 'A'
else
return chr+1

work? Without having to complicate things with ASCII tables...

(not in C notation I know, but it was on purpose ;))
 

Members online

No members online now.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back