Skip to main content
Write a program to read a character in upper case and then print it in lower case in C
#include<stdio.h>
#include<conio.h>
void main()
{
char ch;
clrscr();
printf("\n Enter any character in upper case: ");
scanf("%c", &ch);
printf("\n The character in lower case is: %c", ch+32);
getch();
}
Output
Enter any character in upper case: A
The character in lower case is : a
Write a Program to convert characters of a string into lower case to upper case
#include< stdio.h>
#include<conio.h>
int main()
{
char str[100], upper_str[100];
int i=0, j=0;
clrscr();
printf("\n Enter the string:");
gets(str);
while(str[i] != '\0')
{
if (str [i] >='a' && str [i] <= 'z')
upper_str[j] = str[i] - 32;
else
upper_str[i] = str[i];
i++; j++;
}
upper_str[j]= '\0';
printf(" \n The string converted into upper case is :");
puts(upper_str);
return 0;
}
Output
Enter the string: hello
The string converted into upper case is: Hello
Comments
Post a Comment