Problem statement:- Program to Convert Lowercase to Uppercase without using the inbuilt function.
Data requirement:-
Input Data:- str
Output Data:-str
Output Data:-str
Additional Data:- i
Program in C
Here is the source code of the C Program to Convert Lowercase to Uppercase without using the inbuilt function.
Code:
#include<stdio.h>
#include<string.h>
int main()
{
char str[30];
printf("Enter your String(Lower case):");
scanf("%[^\n]",str);
int i=0;
//convert small letter string to capital letter string
while(str[i]!='\0')
{
if(str[i]>96 && str[i]<123 )//if(str[i]>='a' && str[i]<='z')
str[i]-=32;
i++;
}
printf("Upper case String is :%s",str);
}
#include<string.h>
int main()
{
char str[30];
printf("Enter your String(Lower case):");
scanf("%[^\n]",str);
int i=0;
//convert small letter string to capital letter string
while(str[i]!='\0')
{
if(str[i]>96 && str[i]<123 )//if(str[i]>='a' && str[i]<='z')
str[i]-=32;
i++;
}
printf("Upper case String is :%s",str);
}
Input/Output:
Enter your String(Lower case):csinfo360.com
Upper case String is:CSINFO360.COM
Upper case String is:CSINFO360.COM
Program in C++
Here is the source code of the C++ Program to Convert Lowercase to Uppercase without using the inbuilt function.
Code:
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
string str;
cout<<"Enter your String(Lower case):";
getline(cin,str);
int i=0;
//convert small letter string to capital letter string
while(str[i]!='\0')
{
if(str[i]>96 && str[i]<123 )//if(str[i]>='a' && str[i]<='z')
str[i]-=32;
i++;
}
cout<<"Upper case String is: "<<str;
}
Input/Output:#include<cstring>
using namespace std;
int main()
{
string str;
cout<<"Enter your String(Lower case):";
getline(cin,str);
int i=0;
//convert small letter string to capital letter string
while(str[i]!='\0')
{
if(str[i]>96 && str[i]<123 )//if(str[i]>='a' && str[i]<='z')
str[i]-=32;
i++;
}
cout<<"Upper case String is: "<<str;
}
Enter your String(Lower case):csinfo 360 com
Upper case String is: CSINFO 360 COM
Upper case String is: CSINFO 360 COM
Program in Java
Here is the source code of the Java Program to Convert Lowercase to Uppercase without using the inbuilt function.
Code:
import java.util.Scanner;
public class p7 {
public static void main(String[] args) {
Scanner cs=new Scanner(System.in);
String str,str2=" ";
char c = ' ';
System.out.println("Enter your String(Lower case):");
str=cs.nextLine();
str+='\0';
int i=0;
////convert small letter string to capital letter string
while(str.charAt(i)!='\0')
{
if(str.charAt(i)>96 && str.charAt(i)<123 )//if(str.charAt(i)>='a' && str.charAt(i)<='z')
c=(char)(str.charAt(i)-32);
else
c=(char)(str.charAt(i));
str2+=c;
i++;
}
System.out.println("Upper case String is: "+str2);
cs.close();
}
}
public class p7 {
public static void main(String[] args) {
Scanner cs=new Scanner(System.in);
String str,str2=" ";
char c = ' ';
System.out.println("Enter your String(Lower case):");
str=cs.nextLine();
str+='\0';
int i=0;
////convert small letter string to capital letter string
while(str.charAt(i)!='\0')
{
if(str.charAt(i)>96 && str.charAt(i)<123 )//if(str.charAt(i)>='a' && str.charAt(i)<='z')
c=(char)(str.charAt(i)-32);
else
c=(char)(str.charAt(i));
str2+=c;
i++;
}
System.out.println("Upper case String is: "+str2);
cs.close();
}
}
Input/Output:
Enter your String(Lower case):
csinfo360
Upper case String is: CSINFO360
csinfo360
Upper case String is: CSINFO360
Program in Python
Here is the source code of the Python Program to Convert Lowercase to Uppercase without using the inbuilt function.
Code:
str=input("Enter the String(Lower case):")
i=0
ch=''
#convert capital letter string to small letter string
while len(str)>i:
if str[i]>='a' and str[i]<='z' :
ch+=chr(ord(str[i])-32)
else:
ch += chr(ord(str[i]))
i+=1
print("Lower case String is:", ch)
i=0
ch=''
#convert capital letter string to small letter string
while len(str)>i:
if str[i]>='a' and str[i]<='z' :
ch+=chr(ord(str[i])-32)
else:
ch += chr(ord(str[i]))
i+=1
print("Lower case String is:", ch)
Input/Output:
Enter the String(Lower case):csinfo
Upper case String is: CSINFO
Upper case String is: CSINFO
Most Recommend Questions:-
More Questions:-
0 Comments
Please do not Enter any spam link in the comment box