- Get link
- X
- Other Apps
Write a program to convert characters of a strings to upper case
#include<stdio.h>
#include<conio.h>
void main()
{
char str[100],upper_str[100];
int i=0;j=0;
clrscr();
printf("\n Enter the string:");
gets(str);
while(str[i]!='\o')
{
if(str[i]>='a' && str[i]<='z')
{
upper_str[j]=str[i]-32;
}
else
{
upper_str[i]=str[i];
}
i++;
j++;
}
upper_str[j]='\o';
printf("\n The string converted into upper case is:");
puts(upper_str);
getch()
}
Output
Enter the string:hello
The string converted into upper case is:HELLO
#include<stdio.h>
#include<conio.h>
void main()
{
char str[100],upper_str[100];
int i=0;j=0;
clrscr();
printf("\n Enter the string:");
gets(str);
while(str[i]!='\o')
{
if(str[i]>='a' && str[i]<='z')
{
upper_str[j]=str[i]-32;
}
else
{
upper_str[i]=str[i];
}
i++;
j++;
}
upper_str[j]='\o';
printf("\n The string converted into upper case is:");
puts(upper_str);
getch()
}
Output
Enter the string:hello
The string converted into upper case is:HELLO
Comments
Post a Comment