Posts Tagged upper case
endUp
Given a string, return a new string where the last 3 chars are now in upper case. If the string has less than 3 chars, uppercase whatever is there. Note that str.toUpperCase() returns the uppercase version of a string.
endUp(”Hello”) ? “HeLLO”
endUp(”hi there”) ? “hi thERE”
endUp(”hi”) ? “HI”
public String endUp(String str) {
if(str.length() < 3) return(str.toUpperCase());
else return str.substring(0,str.length()-3)+str.substring(str.length()-3).toUpperCase();
}
Program to convert lower case to upper case and print them in to alphabetically order
Posted by admin in C Examples on June 25th, 2009
#include
main()
{
char c1,c2,c3,c4,c5,c6;
printf("enter the charecters\n");
scanf("%c %c %c",&c1,&c2,&c3);
c4=c1-32;
c5=c2-32;
c6=c3-32;
if(c4>c5&&c4>c6)
{
if(c5>c6)
printf("%c %c %c\n",c6,c5,c4);
else
printf("%c %c %c\n",c5,c6,c4);
}
if(c5>c4&&c5>c6)
{
if(c4>c6)
printf("%c %c %c\n",c6,c4,c5);
else
printf("%c %c %c\n",c4,c6,c5);
}
if(c6>c4&&c6>c5)
{
if(c4>c5)
printf("%c %c %c\n",c5,c4,c6);
else
printf("%c %c %c\n",c4,c5,c6);
}
}


Recent Comments