Programming Blog

This blog is about technical and programming questions and there solutions. I also cover programs that were asked in various interviews, it will help you to crack the coding round of various interviews

Wednesday, 3 January 2018

Write a C program to convert the string from upper case to lower case

#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 lower case\n");
    for(i=0;i<=strlen(str);i++){ if(str[i]>=65&&str[i]<=90){
              str1[i] = str[i]+32;                     
         }  
         else{
              str1[i] = str[i];
         }
    }
    printf("Using method1: %s\n",str1);
    for(i=0;i<=strlen(str);i++){
         if(isupper(str[i])){
              str2[i] = str[i]+32;              
         }      
         else{
              str2[i] = str[i];
         }               
    }
printf("Using method2: %s\n",str2);
    getch();
}

No comments:

Post a Comment