on Saturday, 13 April 2013

/* Logic of toUpperCase() in c language */

#include<stdio.h>


void toUpperCase(char *source){
int index=0;

while(source[index]!='\0'){

char ch=source[index];
// first check it is valid alphabet or not

if(!(ch&64)){
index++;
continue;
}


// is already upperCase
if(!(ch&32)){
index++;
continue;
}

switch(ch){
case '64': case '91': case '92': case '93': case '94': case '95':
// case '96': case '123': case '124': case '125': case '126': case '127':
index++;
break;

default:
source[index]=ch&95;  // now actual logic to  convert into uppercase
index++;

}



}

}



void main(){
 char source[]="123abcAgc"; // can supply any input
 toUpperCase(source);
 printf("%s",source);


}

0 comments:

Post a Comment