Why do my int num=42; code doesn't work and shows error | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

Why do my int num=42; code doesn't work and shows error

Plz help

19th Aug 2021, 8:06 AM
8 D SAIRAJ S L.H.S
8 D SAIRAJ S L.H.S - avatar
13 Réponses
+ 2
//Here is the C# version of MD. Ferdous Ibne Abu Bakar's code: using System; namespace Sololearn { class Program { static void Main(string[] args) { int x = 42; Console.Write(x); } } }
19th Aug 2021, 2:10 PM
Brian
Brian - avatar
+ 2
8 D SAIRAJ S L.H.S you tagged C, but I see that you are taking the C# (C Sharp) Sololearn tutorial. They are distinct languages and different environments. That could be the explanation why the C codes do not work for you. Do you mean C#?
19th Aug 2021, 9:24 AM
Brian
Brian - avatar
+ 2
Thanks
19th Aug 2021, 2:15 PM
8 D SAIRAJ S L.H.S
8 D SAIRAJ S L.H.S - avatar
+ 1
//Try this code: #include <stdio.h> int main() { int x = 42; printf ("%d", x); return 0; }
19th Aug 2021, 8:25 AM
Fꫀⲅძ᥆͟ᥙ᥉᯽
Fꫀⲅძ᥆͟ᥙ᥉᯽ - avatar
+ 1
I meant C# (C sharp)
19th Aug 2021, 9:35 AM
8 D SAIRAJ S L.H.S
8 D SAIRAJ S L.H.S - avatar
0
Plz help
19th Aug 2021, 8:06 AM
8 D SAIRAJ S L.H.S
8 D SAIRAJ S L.H.S - avatar
0
Show me you code
19th Aug 2021, 8:06 AM
Fꫀⲅძ᥆͟ᥙ᥉᯽
Fꫀⲅძ᥆͟ᥙ᥉᯽ - avatar
0
int num=42;
19th Aug 2021, 8:07 AM
8 D SAIRAJ S L.H.S
8 D SAIRAJ S L.H.S - avatar
0
Do we have to write something in first line before writing code
19th Aug 2021, 8:08 AM
8 D SAIRAJ S L.H.S
8 D SAIRAJ S L.H.S - avatar
0
Didn't work
19th Aug 2021, 9:08 AM
8 D SAIRAJ S L.H.S
8 D SAIRAJ S L.H.S - avatar
0
//You also could use struct namespace Sololearn { class Program { struct integer{ public int x; } static void Main(string[] args) { integer myNum; myNum.x = 42; Console.Write(myNum.x); } } }
21st Aug 2021, 6:02 AM
Yousif R Wali
Yousif R Wali - avatar
0
Thanks got it
21st Aug 2021, 6:02 AM
8 D SAIRAJ S L.H.S
8 D SAIRAJ S L.H.S - avatar
- 1
You seem to have tagged this Q & A as C#, please correct it, because based on the comments this question is about C not C#
21st Aug 2021, 8:06 AM
Angel Orioha
Angel Orioha - avatar