Count and change case

This program accepts string from user as input.After accepting the string,it finds the length of string and changes the case of string .

The variable str is used to store string.'\0' represents the end of string.So while calculating the length of string ,'\0' is used as terminating point.The string is parsed character by character and the counter cnt is incremented by 1.When '\0' is reached it indicates the end of the string and the variable cnt stores the length of the string str.

The ASCII value of 'A' is 65 and of 'a' is 97.So the difference between the ASCII values is 32.If we want to convert 'A' to 'a',then add 32 to its ASCII value.Similarly,if we want to convert 'a' to 'A' then subtract 32 from its ASCII value.This concept is used for converting string to upper case and lower case.

#include < stdio.h >
#include < conio.h > 
#include < string.h >
count(int cnt,char str[100]);
up(char str[100]);
low(char str[100]);
void main()
{
	char str[100];
	int option,cnt=0;
	clrscr();
	printf("Enter the string\n");
	gets(str);
	while(1)
	{
		printf("1.Count number of characters\n");
		printf("2.Convert the string to upper case\n");
		printf("3.Convert the string to lower case\n");
		printf("4.Exit\n");
		printf("Select the proper option\n");
		scanf("%d",&option);
		switch(option)
		{
			case 1 : count(cnt,str);break;
			case 2 : up(str);break;
			case 3 : low(str);break;
			case 4 : exit(0);
		}
	}
}
count(int cnt,char str[100])
{
	int i;
	cnt=0;
	for(i=0;str[i]!='\0';i++)
	{
		cnt++;
	}
	printf("The total number of characters are %d\n",cnt);
	return;
}
up(char str[100])
{
	int i=0;
	if(str[i]>='a' && str[i]<='z')
	{
		for(i=0;str[i]!='\0';i++)
		{
		str[i]-=32;
		}
	}
	printf("The string in upper case is %s\n",str);
	return;
}
low(char str[100])
{
	int i=0;
	if(str[i]>='A' && str[i]<='Z')
	{
		for(i=0;str[i]!='\0';i++)
		{
			str[i]+=32;
		}
	}
	printf("The string in lower case is %s\n",str);
	return;
}