Change upper / lower case

C program to change lower / upper case of string :

code

#include<stdio.h>
#include<conio.h>

void main()

{

char str[10];

int cas,i=0;

clrscr();
printf(“String in lower / upper case :\n”);

do
{
printf(“Enter your choice :\n”);

printf(“1.Lower case\n2.Upper case\n3.Exit\n”);

scanf(“%d”,&cas);
i=0;
if(cas==1)
{
printf(“\n Enter string to change in lower case :”);
scanf(“%s”,str);

while(str[i] !=’\0′)

{

if(str[i] >= ‘A’ && str[i] <=’Z’)

{

str[i]=str[i]+32;
}
i++;
}

printf(“\nString in lower case :%s\n”,str);
}
else if (cas==2)
{
printf(“\n Enter string to change in upper case :”);

scanf(“%s”,str);

while(str[i] !=’\0′)

{

if(str[i] >= ‘a’ && str[i] <=’z’)

{

str[i]=str[i]-32;
}
i++;
}

printf(“\nString in upper case :%s\n”,str);
}
}while(cas<3);
getch();
}


output

String in lower / upper case :

Enter your choice :

1.Lower case

2.Upper case

3.Exit

1

Enter string to change in lower case :CODDEIT

String in lower case :coddeit

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s