Posts Tagged lower 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();

}

, , , ,

1 Comment

Write a program that converts lower case to uper case and vice versa of a string.

#include<stdio.h>
main()
{
int i=0;
char ch, str[100];
puts("\nEnter the string");
gets(str);
puts("Origial string:: ");
puts(str);
while(str[i]!='\0')
{if(str[i]>=65 && str[i]<=90)
str[i]+=32;
else if(str[i]>=97 && str[i]<=122)
str[i]-=32;
i++;
}
puts("New string:: ");
puts(str);
}

, , ,

1 Comment

Program to convert lower case to upper case and print them in to alphabetically order

#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);
}

}

, ,

No Comments