Read the string and convert it into the uppercase
String : Ajay
output :AJAY
'a' : ASCII value 97
'A' : ASCII value 65
#include<stdio.h>
#include<conio.h>
void main( )
{
char s[50];
int i;
clrscr( );
printf("\nEnter the string :");
gets(s);
i=0;
while(s[i]!='\0')
{
if(s[i]>='a'&&s[i]<='z')
{
/*lowercase,so convert it into uppercase*/
s[i]=s[i]-32;
}
i=i+1;
}
printf("\nResult : %s",s);
getch( );
}
#include<conio.h>
void main( )
{
char s[50];
int i;
clrscr( );
printf("\nEnter the string :");
gets(s);
i=0;
while(s[i]!='\0')
{
if(s[i]>='a'&&s[i]<='z')
{
/*lowercase,so convert it into uppercase*/
s[i]=s[i]-32;
}
i=i+1;
}
printf("\nResult : %s",s);
getch( );
}
Comments
Post a Comment