|
Get 9,000+ Interview Questions with Answers in an eBook
C Source Codes List | Source Code Home
Program :
/* Prg. to convert upper case to lower case or lower case
to upper case depending on the name it is invoked with as
found in argument i.e. () */
#include
#include
void lower_to_upper();
void upper_to_lower();
void main()
{
int n;
clrscr();
printf("\nPlease enter your choice.");
printf("\n(1) for upper to lower conversion.");
printf("\n(2) for lower to upper conversion.");
printf("\nCHOICE:- ");
scanf("%d",&n);
switch (n)
{
case 1:
{
printf("Please enter a string in upper case.");
printf("\nString will be terminated if you press Ctrl-Z.");
printf("\nSTRING:- ");
upper_to_lower();
break;
}
case 2:
{
printf("Please enter a string in lower case.");
printf("\nString will be terminated if you press Ctrl-Z.");
printf("\nSTRING:- ");
lower_to_upper();
break;
}
default:
printf("ERROR");
}
printf("\n\n\n\n\n\t\t\tHAVE A NICE DAY! BYE.");
getch();
}
void upper_to_lower()
{
int i,j;
char c4[80],c3;
for (i=0;(c3=getchar())!=EOF;i++)
c4[i]=(c3>='A' && c3<='Z')?('a' + c3 -'A'):c3;
printf("\nThe lower case equivalent is ");
for (j=0;j='a' && c1<='z')?('A' + c1 -'a'):c1;
printf("\nThe upper case equivalent is ");
for (j=0;j
C Source Codes List | Source Code Home
|
|
|