Program to transform a string into its uppercase without using strupr() function in c-programming.
In this program allows the user to enter any string or character array. Next, it will use For Loop to iterate every character in that string, and convert them to Uppercase.
The value of a in ASCII is 97, if we subtract 32 it becomes 65 which is ASCII value of A.
So, All lowercase characters ASCII value is from 97 to 122 and if we subtract 32 in each lowercase character only then it will become uppercase character.
//program to transform string into uppercase
#include<stdio.h>
#include<conio.h>
void main()
{
char str[50];
int i;
printf("enter the string:-");
gets(str);
for(i=0;str[i];i++){
if(str[i]>='a'&& str[i]<='z')
str[i]=str[i]-32;
}
printf("\n the string is %s",str);
getch();
}
No comments:
Post a Comment