+ 2

Hello everyone...! C++ programmer i have a puzzle for you can you do that its upto you...!

take a sentence like "i am programmer" in lower case letter and convert that into uparcase after execution but don't use c++ library build in funtions use you on logic....

24th May 2017, 5:28 PM
Zeeshan Salam
Zeeshan Salam - avatar
8 Antworten
+ 3
// here is the code no external library rather than iostream #include <iostream> using namespace std; char toUP(char c){ int ascii = int(c); if(ascii >= 97 && ascii <=122) return char(ascii-32); else return c; } int main(){ char inp[40]; cin.getline(inp,40); int len = 0; for(len=0;inp[len]!='\0';len++) inp[len] = toUP(inp[len]); for(int j=0;j<len;j++) cout<<inp[j]; return 0; }
24th May 2017, 5:45 PM
MR Programmer
MR Programmer - avatar
+ 3
what you need ? acc to ur question , I added no library if user enters wrong charecter the program will automatically detect it. what logic ? there is a simple logic​ if the character is smaller case decrease 32 to get the uppercase
24th May 2017, 5:52 PM
MR Programmer
MR Programmer - avatar
+ 2
I don't know C++, but I wrote it in a language I do know anyway myString="i am programmer" for c in myString: if c==" ": print(" ",end='') else: num=ord(c)-32 let=chr(num) print(let, end='') Output: I AM PROGRAMMER
24th May 2017, 6:18 PM
LordHill
LordHill - avatar
+ 2
make it short and understandable its good...4star
24th May 2017, 6:23 PM
Zeeshan Salam
Zeeshan Salam - avatar
+ 1
do that but create your logic
24th May 2017, 5:42 PM
Zeeshan Salam
Zeeshan Salam - avatar
+ 1
good fantastic to the point
24th May 2017, 5:54 PM
Zeeshan Salam
Zeeshan Salam - avatar
0
lol if you can't do that, and you are not of that level so don't say that its my homework lol, hahaha it is just for those peoples who want to make their self professional...
24th May 2017, 5:39 PM
Zeeshan Salam
Zeeshan Salam - avatar
0
a little bit near to my point
24th May 2017, 5:48 PM
Zeeshan Salam
Zeeshan Salam - avatar