+ 3

How To Add Var In PHP C C++ C# Java Kotlin?

This Is A Mess Why I Forgot About Var's Like This /* Created By Catafrancia Mapper Date And Time: 27-7-2020 10:31 AM */ var sft = "But In Swift!" var wod = "World!" var nme = "Sebastian" var yar = 27 var lco = "Spilt, Croatia" var frm = "Solo, Indonesia" var prv = "Jawa Tengah" var ild = "Jawa" var poe = "Samsung Galaxy C9 Pro" var cmp = "Windows 10" print("Hello \(wod)\n") print("Im Introducing Again \(sft)\n") print("Enjoy!\n") print("Name: \(nme)\n") print("Year: \(yar)\n") print("Living Now: \(lco)\n") print("From: \(frm)\n") print("Province: \(prv)\n") print("Island: \(ild)\n") print("Phone Using Now: \(poe)\n") print("Computer Using Now \(cmp)\n") I Need Vars Same Like That In PHP. C. C++ C# Java. Kotlin Please Help Me! The Same As This Link: https://code.sololearn.com/c41501i6jIz2/?ref=app

27th Jul 2020, 3:37 AM
Catafrancia Mapper
Catafrancia Mapper - avatar
24 odpowiedzi
+ 7
Catafrancia Mapper [ School ] Are you looking for equivalent code to your Swift example? If so, here is a version for C#: https://code.sololearn.com/cKy8ZSnuMh2W/?ref=app
27th Jul 2020, 5:44 AM
David Carroll
David Carroll - avatar
+ 4
Catafrancia Mapper [ School ] Here is Java. I'm not sure if there is a cleaner way to do this in Java. This is the way I know of. https://code.sololearn.com/cR9IyE7d12Am/?ref=app
27th Jul 2020, 12:28 PM
David Carroll
David Carroll - avatar
+ 4
Why exactly do you need to do this in so many languages? Is it just for learning?
27th Jul 2020, 1:38 PM
Ore
Ore - avatar
+ 3
You can *auto* keyword in C++ for that purpose. Example :- #include<iostream> int main() { auto a = 57; auto b = "hello" std::cout<<a<<"\n"<<b; } Output :- 57 hello
27th Jul 2020, 4:10 AM
Arsenic
Arsenic - avatar
+ 3
David Carroll String interpolation in C# almost like that of JS Nice one 👍
27th Jul 2020, 5:47 AM
Ipang
27th Jul 2020, 2:56 PM
David Carroll
David Carroll - avatar
+ 2
Catafrancia Mapper [ School ] You are a programmer. Do not expect people to spoon feed you with ready-made code. I have demonstrated the concept, so think of a way to apply it to solve your problem!😤
29th Jul 2020, 6:32 AM
Ore
Ore - avatar
+ 1
I Mean Input: Hello \(world) var world = "World" Output Hello World
27th Jul 2020, 4:49 AM
Catafrancia Mapper
Catafrancia Mapper - avatar
+ 1
Not To Space DowN But To Still On Line
27th Jul 2020, 4:50 AM
Catafrancia Mapper
Catafrancia Mapper - avatar
+ 1
C# Solved!
27th Jul 2020, 1:05 PM
Catafrancia Mapper
Catafrancia Mapper - avatar
+ 1
PHP Solved!
27th Jul 2020, 1:15 PM
Catafrancia Mapper
Catafrancia Mapper - avatar
+ 1
Java Solved!
27th Jul 2020, 1:22 PM
Catafrancia Mapper
Catafrancia Mapper - avatar
+ 1
Kotlin Solved!
27th Jul 2020, 3:42 PM
Catafrancia Mapper
Catafrancia Mapper - avatar
+ 1
*Ore* Just To Tell You I Need To Introduce In Differnt Language Code
28th Jul 2020, 2:33 AM
Catafrancia Mapper
Catafrancia Mapper - avatar
+ 1
Ok
29th Jul 2020, 1:16 AM
Catafrancia Mapper
Catafrancia Mapper - avatar
+ 1
*Ore* I Need Is Not Numbers But Text!
29th Jul 2020, 2:06 AM
Catafrancia Mapper
Catafrancia Mapper - avatar
+ 1
*Ore* Im Not Pro At Language Except JS & HTML
29th Jul 2020, 12:49 PM
Catafrancia Mapper
Catafrancia Mapper - avatar
+ 1
C, C#, and Java(v. 1 - 9): <data type> <variable>; <data type> <variable> = <expression>; C++: auto <variable> = <expression>; <data type> <variable>; <data type> <variable> = <expression>; Java(v. 10+): var <variable> = <expression>; <data type> <variable>; <data type> <variable> = <expression>; Kotlin: var <variable> : <data type>; var <variable> : <data type> = <expression>; val <variable> : <data type> = <expression>; var <variable> = <expression>; val <variable> = <expression>; PHP(v. 1 - 4): <dollar sign(s)> <variable> = <expression>; PHP(v. 5+): <data type> <dollar sign(s)> <variable> = <expression>; <dollar sign(s)> <variable> = <expression>;
29th Jul 2020, 5:47 PM
SapphireBlue
SapphireBlue - avatar
0
So ... input must contain backslash like that? ☝ Hello \(world) And <world> is a variable defined in code right? not user input? (I haven't learned Swift yet) (Edit) In PHP it's easy, given the string is wrapped in double quotes, variables will expand to their respective value. No backslash nor $ sign is necessary. One drawback I noticed though, PHP doesn't process expressions, so if we have an expression a + b * c, we can't put it as is, instead the expression result needs to be stored into a variable, which will be embedded in the string (cmiiw). https://code.sololearn.com/wOsxkcVScSm4/?ref=app
27th Jul 2020, 5:11 AM
Ipang
0
I wanted to write in Dart also but found Solo Learn Doesn't have this support. But JavaScript rocks. Take a look... https://code.sololearn.com/Wxg7qhIIU0xb/?ref=app
28th Jul 2020, 2:12 PM
KR. Tirtho
KR. Tirtho - avatar