Monday, June 25, 2018

Program to change the case of the given string (i.e Upper to lower case or Lower to upper case) - DS (C Program)

#include<stdio.h>
void main()
{
char *s;
char *a;
int i;
clrscr();
printf("Enter the String : ");
gets(s);
for(i=0;*(s+i)!=NULL;i++)
{
*(a+i)=*(s+i);
}
for(i=0;*(s+i)!=NULL;i++)
{
if(*(s+i)>=65 && *(s+i)<=90)
*(s+i)=*(s+i)+32;
else if(*(a+i)>=97 && *(a+i)<=122)
*(a+i)=*(a+i)-32;
}
printf("\nString in Lowercase: \n >>  ");
for(i=0;*(s+i)!=NULL;i++)
{
printf("%c",*(s+i));
}
printf("\n\nString in Uppercase: \n >>  ");
for(i=0;*(s+i)!=NULL;i++)
{
printf("%c",*(a+i));
}
getch();
}

No comments:

Post a Comment