#include<stdio.h>
#include<string.h>
int main(){
char str[100],str1[100],str2[100];
clrscr();
printf("Enter any string:");
scanf("%s",str);
int i;
printf("Converting to upper case\n");
for(i=0;i<=strlen(str);i++){ if(str[i]>=97&&str[i]<=122){
str1[i] = str[i]-32;
}
else{
str1[i] = str[i];
}
}
printf("Using method1: %s\n",str1);
for(i=0;i<=strlen(str);i++){
if(islower(str[i])){
str2[i] = str[i]-32;
}
else{
str2[i] = str[i];
}
}
printf("Using method2: %s\n",str2);
getch();
}
#include<string.h>
int main(){
char str[100],str1[100],str2[100];
clrscr();
printf("Enter any string:");
scanf("%s",str);
int i;
printf("Converting to upper case\n");
for(i=0;i<=strlen(str);i++){ if(str[i]>=97&&str[i]<=122){
str1[i] = str[i]-32;
}
else{
str1[i] = str[i];
}
}
printf("Using method1: %s\n",str1);
for(i=0;i<=strlen(str);i++){
if(islower(str[i])){
str2[i] = str[i]-32;
}
else{
str2[i] = str[i];
}
}
printf("Using method2: %s\n",str2);
getch();
}
No comments:
Post a Comment