Saturday, May 22, 2010

1.write a c program to accept a string and convert it to upper case without using to upper(),without using poi

here some code...





char str[20]="aBcdeG_er23d*d";


int index=0;





while(str[index]!='\0')


{





if ((str[index]%26gt;='a') %26amp;%26amp; (str[index]%26lt;='z'))


{


str[index]=str[index]-32


}





index++;


}





cout%26gt;%26gt;str%26gt;%26gt;endl;








thank you reading my poor help...

1.write a c program to accept a string and convert it to upper case without using to upper(),without using poi
Huge hint: www.asciitable.com
Reply:I don't know how to write in C, but I can trry to give you some basic ways of convertng to uppercase:


Im not sure what poi means but i think you could compare each letter in the string, using a loop, to an array containing the alphabet and create another identical string with uppercase letters, if that made any sence...





There is a way to compare each of the letters in the string variable in ascii format and i think you can then use a formula to convert that letter to uppercase


for example, in acsii, the decimal equivilant to "a" is "97" and "A" is "65", "b" is "98" and "B" is 66 and so on, so you can maybe make something like this (remember, I cant program is c..): if ((Integer)firstLetter.inASCII()%26gt;=97%26amp;%26amp;(In... then (Integer)firstLetter.inASCII()-22=newFir... I dont know if this made any sence to you, if I new more about C then I could be more specific, maybe you can go somewhre with this


No comments:

Post a Comment